File tree Expand file tree Collapse file tree 1 file changed +26
-28
lines changed
exercises/practice/meetup/.meta Expand file tree Collapse file tree 1 file changed +26
-28
lines changed Original file line number Diff line number Diff line change @@ -25,36 +25,34 @@ def leapYear (year : Nat) : Bool :=
2525 (year % 4 == 0 ) && ((year % 100 != 0 ) || (year % 400 == 0 ))
2626
2727def daysInMonth (month : Month) (year : Nat) : Nat :=
28- match month.val with
29- | 1 => 31
30- | 2 => if leapYear year then 29 else 28
31- | 3 => 31
32- | 4 => 30
33- | 5 => 31
34- | 6 => 30
35- | 7 => 31
36- | 8 => 31
37- | 9 => 30
38- | 10 => 31
39- | 11 => 30
40- | 12 => 31
41- | _ => panic "impossible month"
28+ match month with
29+ | ⟨1 , _⟩ => 31
30+ | ⟨2 , _⟩ => if leapYear year then 29 else 28
31+ | ⟨3 , _⟩ => 31
32+ | ⟨4 , _⟩ => 30
33+ | ⟨5 , _⟩ => 31
34+ | ⟨6 , _⟩ => 30
35+ | ⟨7 , _⟩ => 31
36+ | ⟨8 , _⟩ => 31
37+ | ⟨9 , _⟩ => 30
38+ | ⟨10 , _⟩ => 31
39+ | ⟨11 , _⟩ => 30
40+ | ⟨12 , _⟩ => 31
4241
4342def monthOffset (month : Month) : Nat :=
44- match month.val with
45- | 1 => 307 -- offset from the end of February
46- | 2 => 338
47- | 3 => 1
48- | 4 => 32
49- | 5 => 62
50- | 6 => 93
51- | 7 => 123
52- | 8 => 154
53- | 9 => 185
54- | 10 => 215
55- | 11 => 246
56- | 12 => 276
57- | _ => panic "impossible month"
43+ match month with
44+ | ⟨1 , _⟩ => 307 -- offset from the end of February
45+ | ⟨2 , _⟩ => 338
46+ | ⟨3 , _⟩ => 1
47+ | ⟨4 , _⟩ => 32
48+ | ⟨5 , _⟩ => 62
49+ | ⟨6 , _⟩ => 93
50+ | ⟨7 , _⟩ => 123
51+ | ⟨8 , _⟩ => 154
52+ | ⟨9 , _⟩ => 185
53+ | ⟨10 , _⟩ => 215
54+ | ⟨11 , _⟩ => 246
55+ | ⟨12 , _⟩ => 276
5856
5957def weekConcludes (month : Month) (week : Week) (year : Nat) : Nat :=
6058 match week with
You can’t perform that action at this time.
0 commit comments