Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
22
Task/Doomsday-rule/11l/doomsday-rule.11l
Normal file
22
Task/Doomsday-rule/11l/doomsday-rule.11l
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
F isleap(year)
|
||||
R year % 4 == 0 & (year % 100 != 0 | year % 400 == 0)
|
||||
|
||||
F weekday(year, month, day)
|
||||
V days = [‘Sunday’, ‘Monday’, ‘Tuesday’,
|
||||
‘Wednesday’, ‘Thursday’, ‘Friday’, ‘Saturday’]
|
||||
V dooms = [[3, 7, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5],
|
||||
[4, 1, 7, 4, 2, 6, 4, 1, 5, 3, 7, 5]]
|
||||
|
||||
V c = year I/ 100
|
||||
V r = year % 100
|
||||
V s = r I/ 12
|
||||
V t = r % 12
|
||||
V c_anchor = (5 * (c % 4) + 2) % 7
|
||||
V doomsday = (s + t + (t I/ 4) + c_anchor) % 7
|
||||
V anchorday = dooms[isleap(year)][month - 1]
|
||||
V weekday = (doomsday + day - anchorday + 7) % 7
|
||||
R days[weekday]
|
||||
|
||||
L(year, month, day) [(1800, 1, 6), (1875, 3, 29), (1915, 12, 7),
|
||||
(1970, 12, 23), (2043, 5, 14), (2077, 2, 12), (2101, 4, 2)]
|
||||
print(‘#.-#02-#02 -> #.’.format(year, month, day, weekday(year, month, day)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue