Log in to get your input and submit your answers.
Day 15: Rambunctious Recitation
To pass the time during an excruciatingly long C++ compilation in the cluster, a group of students in the back row starts playing an old memory and recitation game.
The rules are simple but deceptive. Players take turns speaking numbers aloud (turn 1, turn 2, etc.):
- The game begins with the starting numbers (your puzzle input). Each is spoken in its respective opening turn.
- Then, on each subsequent turn, players look at the most recently spoken number (from turn
t - 1): - If that number was spoken for the very first time in the game, the player speaks
0. - Otherwise, the number had been spoken before. The player calculates how many turns apart the two most recent occurrences were (
(t - 1) - previous_turn).
Part 1
You decide to write a simulator to predict the sequence ahead of time and beat everyone at the table.
Example
Consider starting numbers: 0,3,6:
- Turn 1:
0(1st starting number) - Turn 2:
3(2nd starting number) - Turn 3:
6(3rd starting number) - Turn 4: the last number (
6) was brand new -> speak0. - Turn 5: the last number (
0) had been spoken at turn 4 and turn 1 ->4 - 1 =3. - Turn 6:
3was spoken at turns 5 and 2 ->5 - 2 =3. - Turn 7:
3was spoken at turns 6 and 5 ->6 - 5 =1. - Turn 8:
1was brand new -> speak0. - Turn 9:
0was spoken at turns 8 and 4 ->8 - 4 =4. - Turn 10:
4was brand new -> speak0.
Continuing the game with these starting numbers, the 2026th number spoken would be 175.
Simulate the game using your own starting numbers. What will be the 2026th number spoken?