Discussion thread for day 8 of the Advent of Code - https://adventofcode.com/2025/day/8
I couldn't do it in real time today so I took my time.
My solution is macro solution. The difference between Part 1 and 2 is only ending condition.
And for the first time, I used the concatenate distinct option in the Summarize tool.
Part 2 macro:
Day 8
I create another solution inspired by @DaisukeTsuchiya . I created the workflow which will stop when the answer comes using Iterative macro.
First one in a while where I have something exciting to talk about. No special insight on Part1 but if you're stuck on Part2 the spoiler below will drastically simplify the problem.
Part 1, Dual Macro solution, not that different from the others. Possible I need to lean about make group. I like to solve problems like this with nested iterative Macros where the inner one assembles a group and the outer one handles removing that group from the data. That way I get to use iteration.count to enumerate the sets in the out macro and the inner macro doesn't have to keep track of anything except "find every node connected to this one." Single Macro solution is faster, but I find the nested Macros easy to build, especially when I'm tired and this problem didn't seem complex enough to have a need for speed.
Part 2 is the exciting part.
Revisited this puzzle after discussing with @Hub119 and @CoG on WhatsApp.
Implemented improvements:
- Applied more rigorous logic to judge if forming single circuit, that doesn't rely on nature of luckiness in given data
- Cater for dynamic input(sample or my own) by using nested Macro(Iteration Macro inside Batch Macro) to rewrite the parameter for conditional expression via Control Parameter.
- Stop iteration once the result is found
Day 8 is finally complete! Definitely leaned on the community for some much needed help, but I am really happy that I did, as I ended up learning so many new tricks (Explanation and shoutouts can be seen in my reflection)! We live to see another day, and I am excited to take on the 9th challenge.
My Solutions:
The macro used in Part 2
My Reflection:
waste too much time on misunderstand...
the method of calculate distance and i thought it skip the count of connection if there already in circuit.
start of bitmask is create in formula
padleft("0",[Max_recordID],"0")
the multi-row formula, wish it have function that replace specific character where it will simplify the formula.
if isnull([row-1:bitmask]) then
Left(
Left([BitMask],[RecordID]-1)+"1"+Substring([BitMask],[recordid],1000),
[Source_recordID]-1)
+"1"+substring(
Left([BitMask],[RecordID]-1)+"1"+Substring([BitMask],[recordid],1000),
[source_recordID],1000)
else
Left(
Left([row-1:BitMask],[RecordID]-1)+"1"+Substring([row-1:BitMask],[recordid],1000),
[Source_recordID]-1)
+"1"+substring(
Left([row-1:BitMask],[RecordID]-1)+"1"+Substring([row-1:BitMask],[recordid],1000),
[source_recordID],1000)
endif
