AoC 2020 D15: Rambunctious Recitation
| Problem statement | Source code | Tags: Brute forceData structures
← Previous Back to AoC Index Next →
This is literally just simulating the game rules, no questions asked. While 30,000,000 turns is a lot, if we have an algorithm, it's still feasible. The only bottleneck is finding the last occurrence of a number. Instead of storing all numbers physically in an array, notice that previous occurrences of the same number are irrelevant, so we should instead maintain a dictionary that maps each number to its last occurrence index.