Now that's what I call Advent of Code! I'm happy with the algorithm for the most part. I'm sure it could be improved, but I paired up all boxes and pushed them into a BinaryHeap based on their squared distances, then popped the number based on the number of connections to consider (1000 for the real input). These I pushed into a set of "network" HashSets. This is the part I'm least happy with. I iterate the vector of networks to match each point to a network, and if they're both in a network, I extend the earlier one from the later and remove the later. I considered a lot of ways to improve this, but couldn't come up with one that wouldn't be either buggy or inefficient. I'll probably look at the Reddit solutions thread to see how other people tackled it.
Part 2 was really similar in execution to part 1, but continuing until all points were in a network and there was only one network, and keeping track of the last pair added.
Whew, this one was just the right amount of challenging and fun. Most of the days were pretty easy before today's. Now all we're missing is a nice A* problem.
#AdventOfCode #AdventOfCode2025 #AdventOfCode2025Day8 #AdventOfCode2025Day08 #Day8 #Day08 #Rust #RustLang #Programming #CodingChallenges
