Discussion thread for day 3 of the Advent of Code - https://adventofcode.com/2025/day/3
I really love Macros. Was able to nail it first time between nailing Sample data versus Real Data.
Part2 Macro captured some Part1 concepts, of course, but expanded to find any quantity of digits you set. So when I set it up to only 2 digits it solved part 1 too.
Day 3 complete! Cool challenge that definitely scaled up from part 1 --> part 2. Honestly, at this point, I am just happy to still see my name without scrolling on the leaderboards because these are tough!! See you all tomorrow😀
My Solutions:
My Reflection:
First day with a macro, and the workflows are certainly growing too! In terms of which part was most challenging, I found this one the opposite of yesterday's. I had an idea early on, but it took a little while to build the solution. Looking forward to tomorrow's challenge!
2) Choosing the battery sounded straight forward enough but then I realised, I needed to make sure I had at least, one battery to the right of my chosen battery, in order to ensure I could make the full bank, of 2 batteries. With this in mind, if I temporarily remove the last battery from my list, then I don't need to worry about having enough left, as I have the temporarily removed one in "reserve". To remove this battery, I took the maximum position ID from the list, then filtered out any battery with that ID.
3) Now with enough in reserve, I can freely choose, the largest battery, from the remaining list. I used a sort descending and then a sample tool to achieve this.
4) With the first battery per Line ID (aka bank), selected, I now needed to figure out the second battery. The only rule, is that the second battery, must appear after the first one. Translating this into the workflow means that the Position ID of the second battery, must be greater than the position ID of the first battery. Using a join followed by a filter, we can isolate this list.
5) Using the same sort sample trick as before, we can use the list we created, to help find the highest value battery, of those to the right of our first choice.
6) Finally, we need to combine the first and second battery values together to get the Joltage per bank. Then simply sum the Joltage to get to the answer.
Although the steps in the iterative, are almost identical the steps 2- 4 above, Ill briefly explain the changes.
1) In the original step 2 above, we removed the bottom battery from our list, and kept it in "reserve". This allowed us to choose the greatest battery value, from those that remained. As we are now working with a 12 batterie bank instead of just 2, we need to keep more in reserve. For the first iteration, we need to keep 11, batteries in reserve. Then 10 are reserved in the second iteration, and so on. I achieved this by making a small adjustment to the filter tool, using the engine iteration number.
2) Step three from above, is exactly the same inside the macro, as it was out. The next difference is simply with the outputs. After step 3 is complete, we have found the best battery per Line ID, so this is then output from the macro.
Like before, the list of batteries is then filtered down so we have only those that appear to the right of the previously chosen batteries. However, at this stage I have also added a statement to remove all records from the loop, on the 12 iteration.
3) Out of the iterative macro, I then get a list of all the chosen batteries with their Line IDs and Position IDs attached.
4) I used a sort and summarise tool, to concatenate these individual batteries, back into their corresponding banks (Line IDs).
5) Finally, like in part one, the Joltages are summed to arrive at the final answer.
I reworked my copy and paste mess to use an iterative macro. The macro works for both parts.
My first macro in AOC 2025. Unfortunately.
This is where the difficulty really ramped up for me.
I solved part 1 with some effort, but not too bad. Then I got to part 2 and got totally in my head. You ever have it where you start with something and then just can't get that idea out of your head and it ends up getting in the way? Well that's what happened to me. Part 1 was obsessively in my head to the detriment of thinking through part 2.
In the end, I studied up on a variety of other's solutions for part 2 and ultimately adapted @gawa's iterative macro (credit where credit is due). Thank you and nicely done gawa!
Here's my solution. No narrative this time around, my brain is fried after this plus the day job...
... on to day 4...? 😅
