AoC# 2024 - Day 14: Restroom Redoubt
It’s Advent of Code time 🎄
Advent of Code is an Advent calendar of small programming puzzles for a variety of skill levels that can be solved in any programming language you like.
We’ve already dodged guards this year, and on Day 14 we’re avoiding security robots!
Part 1 ⭐️
Straightforward enough, once I’d fixed a couple of off-by-1 errors: I’d taken the tile space as given but used zero-indexing for the robot positions; and teleporting with a negative velocity to a position less than zero needed to account for zero being a space/move.
Part 2 ⭐️
An unexpected twist…
But how’s this for a vague requirement:
most of the robots should arrange themselves into a picture of a Christmas tree.
What is the fewest number of seconds that must elapse for the robots to display the Easter egg?
What, exactly, are we looking for?! No hint of where in the space or what size this tree could be1 meant that my first thought was to compare the left half of the space mirrored the right2, but the “most of the robots” gave me doubt this would work.
My next thought was to eyeball the output… it was easy to create a simple console output map of the robot’s locations but it was hard to track, so I switched to rendering ~10,0003 images as they’d be easier to page through in the Finder:
I wasn’t the only one with this idea 😄
-
There wasn’t a hint about trees in the previous year’s puzzle referenced in the introduction; it concerns keypad entry codes. ↩
-
Not a bad thought, given Part 1 has us counting robots in quadrants. ↩
-
10,000 was chosen at random. I figured I could just keep generating blocks of images if need be. Turns out my answer was in the first block. ↩