60 lines
2.2 KiB
Plaintext
60 lines
2.2 KiB
Plaintext
; About the task
|
|
John Conway (1937-2020), was a mathematician who also invented several mathematically
|
|
oriented computer pastimes, such as the famous Game of Life cellular automaton program.
|
|
Dr. Conway invented a simple algorithm for finding the day of the week, given any date.
|
|
The algorithm was based on calculating the distance of a given date from certain
|
|
"anchor days" which follow a pattern for the day of the week upon which they fall.
|
|
|
|
; Algorithm
|
|
The formula is calculated assuming that Sunday is 0, Monday 1, and so forth with Saturday 7, and
|
|
|
|
doomsday = (Tuesday(or 2) + 5(y mod 4) + 4(y mod 100) + 6(y mod 400)) % 7
|
|
|
|
which, for 2021, is 0 (Sunday).
|
|
|
|
To calculate the day of the week, we then count days from a close doomsday,
|
|
with these as charted here by month, then add the doomsday for the year,
|
|
then get the remainder after dividing by 7. This should give us the number
|
|
corresponding to the day of the week for that date.
|
|
|
|
Month Doomsday Dates for Month
|
|
--------------------------------------------
|
|
January (common years) 3, 10, 17, 24, 31
|
|
January (leap years) 4, 11, 18, 25
|
|
February (common years) 7, 14, 21, 28
|
|
February (leap years) 1, 8, 15, 22, 29
|
|
March 7, 14, 21, 28
|
|
April 4, 11, 18, 25
|
|
May 2, 9, 16, 23, 30
|
|
June 6, 13, 20, 27
|
|
July 4, 11, 18, 25
|
|
August 1, 8, 15, 22, 29
|
|
September 5, 12, 19, 26
|
|
October 3, 10, 17, 24, 31
|
|
November 7, 14, 21, 28
|
|
December 5, 12, 19, 26
|
|
|
|
; Task
|
|
|
|
Given the following dates:
|
|
|
|
* 1800-01-06 (January 6, 1800)
|
|
* 1875-03-29 (March 29, 1875)
|
|
* 1915-12-07 (December 7, 1915)
|
|
* 1970-12-23 (December 23, 1970)
|
|
* 2043-05-14 (May 14, 2043)
|
|
* 2077-02-12 (February 12, 2077)
|
|
* 2101-04-02 (April 2, 2101)
|
|
|
|
<br>
|
|
Use Conway's Doomsday rule to calculate the day of the week for each date.
|
|
<br><br>
|
|
|
|
; see also
|
|
* [[wp:Doomsday rule|Doomsday rule]]
|
|
* [https://www.archim.org.uk/eureka/archive/Eureka-36.pdf Tomorrow is the Day After Doomsday (p.28)]
|
|
|
|
|
|
|
|
|