This is terrible, but it's Christmas and I don't want to solve this intense graph theory problem right now. I fed the parsed graph into graphviz so I could see where the connections were, then had the code sever them and calculate the independent graph sizes.
Maybe I'll find a real solve for this later...but probably not.
Very, very shamelessly stolen from the r/adventofcode main thread where everyone was using this "Z3" library to solve equations. I'm not good at math, and this problem feels more like Advent of Linear Algebra than Code. Although it appears that Z3 doesn't work on mac since I had to switch back to my desktop PC for this one :(.
I solved part 1 the naive way and was reasonably happy with it. I was successfully using that solution with some negative-modulus junk to brute force part 2 (I could get the correct answer for the example data's smaller number of steps), but there was no way it was completing in a reasonable amount of time or without blowing all my RAM. I was at a complete loss for how to solve part 2 the "smart" way, so I learned from this video: https://www.youtube.com/watch?v=9UOMZSL0JTg
I understand why this works now, but I was not going to be getting it on my own (nor did I really want to spend the time it would have taken me to attempt to arrive at a similar solution).
Not sure how I feel about this one. I don't mind a "day off" of sorts, but there were just so. many. words in the puzzle that boiled down to such a straightforward implementation. I guess this is practice of "implement detailed requirements exactly to spec" or something.
Part 1 was my own, but was far, far too slow for part 2. I couldn't find a way to optimize it and didn't want to get stuck on the day forever, so I cribbed a solution from a Reddit post explaining a much faster way to solve it.
I...I know there's a way to map all the ranges together to build intersections and make a smart decision about this, but I just...don't really want to do that. This brute force approach finishes in about 55 seconds in Debug and 5 seconds in Release on my PC in a single thread, which...is fine. For now.