This is Day 14 of Advent of Code 2023! If you would like to solve the problems before looking at the solution, you can find them here.

In part 1 of Day 14, we have one of my favorite puzzles this edition, simply because it takes me back to my childhood when I used to have a toy that functioned in a way very similar to this. We have a matrix with some fixed pegs denoted by hashes and movable circles denoted by Os. For the first part, we have to see how far north each movable circle can go. This is pretty easy - I rotate the grid because I prefer working with rows over columns and then I move each circle as far left as is possible by keeping track of empty spaces available and resetting when you hit a peg. Hitting a circle does not affect the empty space counter because it moves to the left most space available and leaves its own space empty. Pretty easy one today! Click here to jump to the part 2 discussion.

For part 2 of Day 14, here is where things get interesting, we have to move things in the four cardinal directions over and over, kind of as if you were tilting the board in a circle. All four directions, a BILLION times. One of the key things that I figured out early on was that I would have to check for loops in the movement - we can do this by keeping a list of what position has been seen before and stopping when we find a repeat. This makes the bit about a billion repetitions irrelevant as I found a loop around a hundred cycles in. Not sure if that was lucky or intended but I did see someone come up with a grid that would not loop even in a billion iterations!

That's all folks! If you made it this far, enjoy some AI art generated by u/encse using the prompt for this puzzle.

Cheers,

Devang