Skip to content

Commit ed9c640

Browse files
authored
Remove the solution from meetup stub. (#492)
Fix #491
1 parent b57e6f9 commit ed9c640

File tree

1 file changed

+2
-42
lines changed

1 file changed

+2
-42
lines changed

exercises/practice/meetup/meetup.ml

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,48 +6,8 @@ type schedule = First | Second | Third | Fourth | Teenth | Last
66
type weekday = Monday | Tuesday | Wednesday | Thursday
77
| Friday | Saturday | Sunday
88

9+
(* result type (year, month, day_of_month) *)
910
type date = (int * int * int)
1011

11-
let diff_days (d1: weekday) (d2: weekday): int =
12-
let weekday_to_int = function
13-
| Monday -> 0
14-
| Tuesday -> 1
15-
| Wednesday -> 2
16-
| Thursday -> 3
17-
| Friday -> 4
18-
| Saturday -> 5
19-
| Sunday -> 6 in
20-
(weekday_to_int d1 - weekday_to_int d2) % 7
21-
22-
let day_of_week (d: Date.t): weekday =
23-
match Date.day_of_week d with
24-
| Sun -> Sunday
25-
| Mon -> Monday
26-
| Tue -> Tuesday
27-
| Wed -> Wednesday
28-
| Thu -> Thursday
29-
| Fri -> Friday
30-
| Sat -> Saturday
31-
32-
let schedule_to_int = function
33-
| First -> 0
34-
| Second -> 1
35-
| Third -> 2
36-
| Fourth -> 3
37-
| Teenth -> 4
38-
| Last -> 5
39-
40-
let add_days base days =
41-
Date.Period.day days |> Date.add base
42-
4312
let meetup_day schedule weekday ~year ~month =
44-
let base = Date.make year month 1 in
45-
let calc_offset start = start + diff_days weekday (add_days base start |> day_of_week) in
46-
let day = calc_offset @@ match schedule with
47-
| Teenth -> 12
48-
| Last -> 21 + max 0 (Date.days_in_month base - 28)
49-
| _ -> 7 * schedule_to_int schedule in
50-
let core_date = add_days base day
51-
in (Date.year core_date,
52-
Date.month core_date |> Date.int_of_month,
53-
Date.day_of_month core_date)
13+
failwith "'meetup_day' is missing"

0 commit comments

Comments
 (0)