-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathleap_year.exem
44 lines (35 loc) · 927 Bytes
/
leap_year.exem
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""
leapYear(int year):
returns true iff
* the year is divisible by 4 and not divisible by 100 (eg, 2012, 2016, 2020, 2024)
or
* the year is divisible by 400 (eg, 2000, 2400, 2800)
"""
<399 # 399 is not a leap year because all the other conditions are not met: elif True == else
True
>False # Meaning, not a leap year.
<400 # 400 is a leap year because:
i1 % 400 == 0
>True
<2012 # Similarly, this make 2012 a leap year:
i1 % 4 == 0 and i1 % 100 != 0
>True
<2000 # This is a leap year for a different reason:
i1 % 400 == 0
>True
<2013 # Another "none of the above", so 2013 /isn't/ a leap year.
True
>False
<2014 # Ditto.
True
>False
<2015
True
>False
<2016
i1 % 4 == 0 and i1 % 100 != 0 # This truth is what qualifies 2016 as a leap year.
>True
<2020 # Assertion-less examples are ignored re: function synthesis and drive unit test creation only.
>True
<2400
>True