Conway's algorithm β type the weekday as 0..6
Technique: Conway's Doomsday algorithm
You're shown a calendar date β type the day of the week as a single integer.
Answer key:
| Number | Day |
|---|---|
| 0 | Sunday |
| 1 | Monday |
| 2 | Tuesday |
| 3 | Wednesday |
| 4 | Thursday |
| 5 | Friday |
| 6 | Saturday |
(Same convention as JS Date.prototype.getDay(). The compact bar above the input field repeats this map.)
Each century has a "Doomsday" β a known weekday for a fixed reference date.
| Century | Anchor day | Number |
|---|---|---|
| 1700s | Sunday | 0 |
| 1800s | Friday | 5 |
| 1900s | Wednesday | 3 |
| 2000s | Tuesday | 2 |
| 2100s | Sunday | 0 |
Mnemonic: anchors cycle Sun β Fri β Wed β Tue β Sun (a "step back" of 5 then 2 then 1 then 5...).
For year YY (last two digits): the year's Doomsday is
(YY + βYY / 4β) mod 7 days after the century anchor.
Example: 1992 β YY=92, β92/4β=23, sum=115, 115 mod 7 = 3. 1900s anchor is Wed (3), so 1992's Doomsday is Wed + 3 = Saturday.
The following dates ALL fall on the year's Doomsday:
Take the closest Doomsday in the target month. Compute (target_day β doomsday_day) mod 7 β that's how many weekdays to advance from the year's Doomsday.
Every question has a 30 second shot clock. Type the integer 0..6 and press Enter.
Bug, wording issue, or polish suggestion β all go straight into the dogfood backlog.