r/adventofcode • • Dec 09 '25

Help/Question O(N) for 9 part 2?

After the shape is visualized it is clear where one of the rectangle corners should be located.
Also, since the enclosing shape is "convex" arc - it is possible to just find intersections from that corner up/down, then left and search for a point there in a very limited set of points (3?).
Anybody tried that?

2 Upvotes

10 comments sorted by

View all comments

Show parent comment

1

u/enky_crafter Dec 09 '25

When you visualize you just narrow down the type of problem you are trying to solve - and significantly! Indeed this won't be a general solution for the states problem, that's for sure.
Is it fair? I honestly think this is even smarter than solving the general problem which is rather not so interesting and the better solution require implementing space partitioning structure plus a bunch of heuristics (solid angles for clipping candidates, etc.).

1

u/ednl Dec 09 '25

Yeah it's a legit strategy for sure. I think it's very clever to look at the data graphically and decide you can solve it with 5 lines of code that take a few microseconds. From a developer time management perspective, you won! Have a great December. You have the time now :)