the doomsday machine
John Conway's Doomsday algorithm, implemented in C++ from handwritten notes โ and running live on this site as the unmodified compiled binary.
What is this?
Give it any date โ it tells you the day of the week using only mental-math steps. No date library, no calendar lookup. It's the same trick human "calendar calculators" perform in their heads, and it was invented by mathematician John H. Conway.
The C++ program behind this site (doomsday.cpp) was written from scratch, by hand, from handwritten notes โ then compiled unmodified to WebAssembly, so what runs in your browser is the exact same binary that runs in a Linux terminal. Nothing was rewritten or faked for the web: the prompts, the quirks, even the typos are the real program. Feed it a year, a month and a day, and it walks the algorithm live โ century anchor, year doomsday, month anchor โ and prints the weekday.
Conway designed the method so the whole calculation fits in your head: a handful of anchor dates per year, one easy formula, and mod 7. With a bit of practice most people land any date in under five seconds โ faster than opening a calendar app. This site teaches the method step by step, lets you run the original machine, and then trains you against the clock.
Beyond this page there are two rooms:
โ๏ธ the terminal
The original doomsday.cpp, compiled to WebAssembly and driving a fake VS Code terminal โ typos, backspaces, blinking cursor and all. Every answer comes from the real binary.
๐ฎ the game
Once you've learned the algorithm, race the clock: random dates across four difficulty tiers up to brutal (any date in years 1โ9999). Streaks, hints, achievements, and a daily challenge.
play โThe algorithm in four steps
Every year has a "doomsday" โ a weekday that a known set of easy dates all fall on (4/4, 6/6, 8/8, 10/10, 12/12, 5/9, 9/5, 7/11, 11/7, Pi Dayโฆ). Find the doomsday, hop to your date.
Century anchor
Anchors cycle over 400 years: 1800s โ Friday, 1900s โ Wednesday, 2000s โ Tuesday, 2100s โ Sunday. The code derives this from a 2000 = Tuesday base instead of a hardcoded table.
Year's doomsday
For the last two digits y of the year:
doomsday = anchor + (y / 12) + (y % 12) + ((y % 12) / 4) (mod 7)
Month's anchor date
Each month has a date guaranteed to land on the doomsday:
| Month | Doomsday | Month | Doomsday |
|---|---|---|---|
| Jan | 3rd (4th in leap years) | Jul | 11th |
| Feb | 28th (29th in leap years) | Aug | 8th |
| Mar | 14th ("Pi day") | Sep | 5th |
| Apr | 4th | Oct | 10th |
| May | 9th | Nov | 7th |
| Jun | 6th | Dec | 12th |
Step to the target
(day โ month_anchor) mod 7, added to the year's doomsday, gives the weekday.
Worked example โ 21 August 2026
1. 2000s anchor โ Tuesday
2. y = 26: 26/12 = 2, 26%12 = 2, 2/4 = 0 โ 2 + 2 + 2 + 0 = 6 โ doomsday = Saturday
3. August's doomsday is 8/8
4. 21 โ 8 = 13 โก 6 (mod 7) โ Saturday + 6 = Saturday โ
See it in action
Learn it yourself
- start herethe preferred walkthrough
- good oneanother solid explanation
- 2-parterpart 1 ยท part 2
- alt techniquea different mental route
- deep cutsmore Conway ยท heavy math version
- practicewhattheday.com โ the original inspiration