Part 1 was easy: it’s just modulo arithmetic and counting. But part 2 is so unclear, I’m not going to start. A Christmas tree? That’s such a vague description. I’m not going to bother writing code, only to find out my idea of a Christmas tree wasn’t AoC’s. For all I know, it might have a star on top and balls.
Weird that the description is so unclear. Other problems have really precise requirements. Did I miss something?
For part 2 you need to watch the robot map at many time steps. Of course it is better to filter this output (10,403 different images). First I’ve tried to select only maps with a trianglular area on the top left and top right cleared, without success. Then I’ve looked at ideas on reddit and a good one (more… “scientific”) is to measure robots density on rows and columns. At each time step where one of the densities is above a certain threshold, you display the map.
EDIT: with my data, the tree is drawn mostly in one quadrant. So I can just detect the safety factor of part 1 being below a certain threshold, and voilà…
My mental image of a christmas tree was something like
*
* *
* *
* *
* *
* *
* * * * * *
but much bigger, so density really didn’t spring to mind. My best thought was a 2D FFT and see if there is a significant low frequency component, but that just seemed too much work. I wouldn’t even know where to begin.
Part 2 was pretty lame, but AoC always has at least 1 objects-converge-to-a-shape puzzle. I piped my output to a text file and searched for 11111111... until something interesting came up.
Nice trick. I worked under the assumption it would have to be to solve it in code, though, so that it would also run on other people’s input. In retrospect, I could have stuck with my Excel spreadsheet for day 13. I had a simple 9 column setup with values, solution, cost and total. But for me it’s more about learning a bit about Ada, even though today’s assignment didn’t do much for that.
BTW, I was looking for crates, but I couldn’t find one even with a simple, 1 dimensional FFT. Am I doing something wrong? Don’t such crates exist? Github doesn’t provide anything either.
I was also a little annoyed with the vague goal in part 2. I’ve successfully solved AoC problems like this before: one year you had to figure out a string of text that a robot was painting on the ship, and I don’t think you knew the number of steps, nor was any pattern apparent, but at least you knew it was a string of text, which is still more concrete than this.
If it helps, the problem turns out to be pretty easy:
It’s a picture, so…
like most pictures, it has a frame, so…
just look for a bunch of robots in a row.
I wish I could say I thought that up on my own, but I didn’t. My daughter and I looked through several hundred steps, trying to find a pattern in the robots’ motion and coming up fruitless. I kept wanting to see something like this:
…or something along those lines, but never really saw anything like that. We’d probably have seen the correct solution eventually (and something like that would indeed work, if I’d searched the output with a regex or something to that effect – but not too much like that).
I’ve seen some other approaches. One Reddit poster claimed to have used some sort of pattern, but I don’t think he showed code.