This one was really hard for me. Part 1 wasn't bad at all; I could basically use the entirety of what I did yesterday for it.
Part 2 was really hard. At first, I tried actually building a HashSet of all the red and green tiles, and then a HashSet of all the areas for each pair, and checking them against each other. Needless to say, that wouldn't work. Building the tile HashSet alone would have eaten up more memory than I have on my computer, and I should have realized that immediately looking at my answer to part 1 (which was an area of over 4 billion tiles). I thought that checking a line of green tiles through the area wouldn't necessarily work, because a malicious input could make that not work (two immediate right or left turns could make a pair of adjacent green tile lines that would still work), but it turns out that it works fine for my input. Probably all inputs.
It works. I don't feel totally satisfied with the solution, but it works.
I think a more robust solution could be to trace the outline and fill it with square area units, then for each area to test (ordered from largest to smallest), repeatedly cut area out of it with the green tile squares. If all overlapping areas are tested and there are still un-cut squares, the area is invalid; move on to the next. If the area is cut completely to nothing, then it is the best area. I'm not going to implement this, because it sounds like a total fiddly pain, but I would be interested in seeing somebody else's solution along these lines.
#AdventOfCode #AdventOfCode2025 #AdventOfCode2025Day9 #AdventOfCode2025Day09 #Day9 #Day09 #Rust #RustLang #Programming #CodingChallenges




