:: krowemoh

Thursday | 26 DEC 2024
Posts Links Other About Now

previous
next

Advent of Code 2023 - Day 8

2023-12-10
advent-of-code

Day 8 was about graph traversal and this was fun to do in BASIC. This was relatively straightforward in the first part and then the second part came in like a brick.

The logic of doing it in the second part I sort of get but not really. I cheated and got some hints off reddit and the key insight was to use lowest common multiple of the cycle. Part 2 involved finding multiple starting points and ending points and they would all cycle for awhile before they sync up and all land on their end points together. The problem was that the sync time was going to be stupid long.

Instead what you can do is find the cycle length of each starting point and then it will be the lowest common multiple of set of cycle lengths. This makes sense but the puzzle doesn't say that there is a cycle or that the first you go from A to Z is a single cycle. In my head it seems like you can hit a Z and then continue as part of the cycle and hit another Z. To check of a cycle, you should really count 2 cycles and see if they match. However even this seems like it could just be a repeating pattern until it's not.

I'm probably misunderstanding something with how cycle detection and graphs work.

I finished part 2 by detecting the cycle by counting a cycle as a single A to Z and this did work but I didn't leave the puzzle satisfied.

I also love that other people did the same thing where instead of writing a LCM function, they went online and found a calculator. That is exactly what I did. I love the community aspect of Advent of Code and the memes are a big part of the enjoyment of it.

Day 8