Discussion thread for day 7 of the Advent of Code - https://adventofcode.com/2025/day/7
Today, it was basically a MAP problem that just flowed from above, so it was easy to think about.
P1 seemed like a bit of a detour, but in the end I was kind of making a macro for P2. I created the macro which calculate each route for P1(actually P2), and then I realized I had to calculate the number of hits later. But fortunatelly I had to do was attach a Macro Output tool to the collision detection and it was complete to create the macro.
P2 is a modified version of P1, where I just added a count column and changed the Unique tool to a Summarize tool. While adding the count column for P2, I realised it was a typical AoC pattern count problem.
Maybe I was lucky.
Part 1 macro
Part 2 macro
Finally a little ramp up in the difficulty... luckily I recently wrote a blog post detailing handling splitting versions of reality (playing a game with a quantum die) so I had a good idea of how to handle things in part 2 after I got my data parsed and ready to run through the splitters.
It's messy. Unlike other folks, I cannot connect Part1 and Part2 wisely so needed re-building macro for Part2.
I started building a simple workflow, then thought, "This is AoC, I should protect myself by being smart"... and wow was that a dumb idea. My optimizations massively increased the size and complexity of my workflow requiring a lot of error handling and re-work. For reference here is the macro I used for my first attempt:
After submitting my answers, I re-factored, following the simpler approach I had started with originally:
Happy Solving, y'all!
That was a bit of a difficulty step up, though for me most of the problems were getting the data types right.
Created a bug inside my part 2 Macro that was setting things to Int32 where this year has proven that everything should just be Int64 whether it wants to or now.
Had some fun with part 1 drawing the tree because I built that while I figured out what the sample data was trying to say. That one extra splitter in the sample data that didn't actually get to split, and this count, cost me more time than actually solving part 1.
Part 2 was a neat sort of map problem involving inheritance. If you're stuck on this one, think about the problem as finding how many ways you can reach each position in the current row based on the prior row. Then do it for the next row and so on.
Solved.
I created this diagram and developed the logic.
Rare occasion where my Part 1 macro assisted with Part 2, although got a bit stuck on the modification I needed.
Macro could definitely do with some tidying up bit it's Sunday and the dog won't walk herself 😉
I was able to solve today's problem with a straightforward approach.
For P2, I initially thought about keeping a history for each path, but the number of records exploded. By changing my method to sum the counts at each coordinate, I was able to get the processing time down to 5 seconds.
Initially, over complicated this one as I was trying to account for the beam hitting the edge. Turns out this wasn't needed, so I removed that logic from my answer.
Another day where my parts one and two overlap! Here's my workflow:
Macro:
Part 1 & 2
1) I began by splitting the data into a grid and labelling it with coordinates.
2) Next, I isolated the starting point and labelled it with a count. This is my count of timelines (and obviously just = 1, at the start point)
3) Now for the iterative piece. My macro has two inputs. One being the current position(s) of the beam, and the other being the entire grid / manifold. Over each iteration the grid will stay the same but the current position(s) will be updated via the iterative loop. At the start of each iteration, I updated the Row ID to the row below, then joined to the full grid, to figure out if I had landed on a splitter or not
4) By filtering to the splitters, these records can be both output and updated accordingly, so the beam is tracked in the column to the left and right of the current position.
5) The final step in the macro is to combine all the different beam paths back together. After the splitter, some beams may now be combined. Instead of tracking them both going forward, I decided just to track the one, and simply update the “count”. This meant I always knew how many timelines one beam position could be a part of.
6) Here's the output from the macro.
7) The final step was now nice and simple. To answer part one, I simply needed to count the number of records coming out of the macro. And for part two, I could sum the timeline counts to figure out the total number of timelines (not forgetting to add one, as the initial record wasn’t accounted for).
