Skip to content

Commit 2297ca5

Browse files
authored
adding doctest and fixing a black issue [doomsday]
1 parent f430e3c commit 2297ca5

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

other/doomsday.py

+6-13
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
#!/bin/python3
2-
3-
"""
4-
The doomsday algorithm was invented by John Conway and returns
5-
the week-day (e.g. Sunday/Monday/Tuesday/etc) given
6-
a date (e.g. 24/10/1819).
7-
8-
For more info:
9-
https://en.wikipedia.org/wiki/Doomsday_rule
10-
"""
2+
# For more information on the doomsday algorithm please see: https://en.wikipedia.org/wiki/Doomsday_rule
113

124
_doomsday_leap = [4, 1, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5]
135
_doomsday_not_leap = [3, 7, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5]
@@ -26,9 +18,9 @@ def get_week_day(year: int, month: int, day: int) -> str:
2618
"""Returns the week-day name out of a given date.
2719
2820
>>> get_week_day(2020, 10, 24)
29-
Saturday
21+
'Saturday'
3022
>>> get_week_day(2017, 10, 24)
31-
Tuesday
23+
'Tuesday'
3224
3325
"""
3426
# minimal input check:
@@ -54,5 +46,6 @@ def get_week_day(year: int, month: int, day: int) -> str:
5446

5547

5648
if __name__ == "__main__":
57-
# unit-test:
58-
assert get_week_day(2020, 10, 24) == "Saturday"
49+
import doctest
50+
51+
doctest.testmod()

0 commit comments

Comments
 (0)