I did Part 1 running the simulation step by step. I leveraged one key insight for Part 2: any new obstacle must be placed somewhere on the original path from Part 1. This reduces the search space from 19K to 5K (approx) tiles, and I brute forced it from there.
And the trick for detecting a loop was being on a previously traversed tile and facing the same direction.
Runtime was around 25 minutes single-threaded on an Apple M1 Pro.
[#]AdventOfCode #Swift
=> More informations about this toot | View the thread | More toots from felyashono@disabled.social
=> View adventofcode tag | View swift tag This content has been proxied by September (ba2dc).Proxy Information
text/gemini