#AdventOfCode #AoC
I completed #Day08 of #AdventOfCode2023.
Part 1:
- Difficulty: 3/10
- Workout: 2/10
Part 2:
- Difficulty: 3/10
- Workout: 5/10
Part 1 was a straight simulation: instructions given, parse and table moves, loop for following instructions. Barely a half-hour of work.
Part 2 extends from one start point to several; it just means a list of places mapping to a list of places, instead of place mapping to place.
Brute force, like in part 1, turned out to be not viable: 1.8e9 iterations, and nothing. I tried to find repeatable sequences of places, starting with each place and instruction position, but the volume of data generated was getting too big.
I had to resort to r/AdventOfCode for tips. At once, I found: closed cycles and LCM. It was enough. I quickly found --Z to --Z cycles, and their periods; all multiples of the same number. A quick implementation of GCD, then LCM(a, b) = a * b / GCD(a, b), reduce list of periods by LCM, and done.
Total time, programming and wasting CPU: about 7 hours.