Not really happy with my solution for part 2. I struggled to come up with the right data structure(s) until I worked backwards and wrote the algorithm first, then created the structures I needed for that algorithm. It’s sloppy and built on top of the map/vector I used in Part 1, even though those are clunky and unnecessary.
I tried rewriting it to maintain a free list and allocate from that like some of the other solutions I saw on reddit, but somehow that ended up being even slower.
I’m tired of messing with it, so this one is going in the “good enough” bucket for me.