Day 20 solution

Part 1 was pretty much just day 18 again, but without doors and with an input data parsing skill check. I simplified day 18 and went with a basic Dijkstra algorithm after the DFS to crawl the maze which solved this just fine.

Part 2 messed me up more than I was expecting. The key feature for part 2 is changing up what the Dijkstra solver views as an "adjacent" node and injecting the appropriate depth as we traverse inner/outer portals. The main thing that tripped me up here from part 1 was that I needed to be carrying more data along with portals than just their locations, and I could no longer get away with storing the portals as pairs of their inner/outer locations, so a small refactor was needed. Once I made those corrections, it was mostly a matter of ironing out the "get neighbors" function to adhere to part 2's rules, which took me a lot of debugging to get just right.

Part 2 still took me longer than I'd care to admit. I had problems wrapping my head around the problem.
This commit is contained in:
2022-07-14 14:54:02 -05:00
parent f9f31820ac
commit effd94c09b
6 changed files with 605 additions and 0 deletions

View File

@ -53,6 +53,7 @@ var dayMap = []day{
&days.Day17{},
&days.Day18{},
&days.Day19{},
&days.Day20{},
}
func main() {