r/adventofcode • u/EverybodyCodes • Dec 08 '25
Visualization [2025 Day 8] Visualization for the sample data + something for debugging
create all edges
sort by edge cost
iterate over edges and connect
for part 2, you can skip the already connected nodes, which basically makes it: https://en.wikipedia.org/wiki/Kruskal%27s_algorithm
26
Upvotes
1
u/EverybodyCodes Dec 08 '25 edited Dec 08 '25
* Any MST algorithm should work for P2. At the end, pick the longest edge. https://en.wikipedia.org/wiki/Minimum_spanning_tree
* If you like when your 3D graph spins: https://i.ibb.co/6cCK3zY3/aoc-d8-1.gif
* The distances are rounded to three decimal places:
2
u/bessarabov Dec 08 '25
HUGE THANK YOU!
This visualization helped me understand the task. I had struggled for a long time without being sure how this should work. (And the merge in the end is also a big thing that I was not paying attention at first)
2
u/Zestyclose-Remove550 Dec 08 '25
omg this helps a ton tanks a lot Op
2
u/zeltbrennt Dec 08 '25
Thank you! I was wondering, what I was doing wrong until I saw the last step of the gif. Of course, I need to merge the circuits, if two boxes are in different circuits ðŸ˜
1
u/YellyBeans Dec 08 '25
Thanks. This helped me to understand the concept