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.
37 lines
1.3 KiB
Plaintext
37 lines
1.3 KiB
Plaintext
A
|
|
A
|
|
#################.#############
|
|
#.#...#...................#.#.#
|
|
#.#.#.###.###.###.#########.#.#
|
|
#.#.#.......#...#.....#.#.#...#
|
|
#.#########.###.#####.#.#.###.#
|
|
#.............#.#.....#.......#
|
|
###.###########.###.#####.#.#.#
|
|
#.....# A C #.#.#.#
|
|
####### S P #####.#
|
|
#.#...# #......VT
|
|
#.#.#.# #.#####
|
|
#...#.# YN....#.#
|
|
#.###.# #####.#
|
|
DI....#.# #.....#
|
|
#####.# #.###.#
|
|
ZZ......# QG....#..AS
|
|
###.### #######
|
|
JO..#.#.# #.....#
|
|
#.#.#.# ###.#.#
|
|
#...#..DI BU....#..LF
|
|
#####.# #.#####
|
|
YN......# VT..#....QG
|
|
#.###.# #.###.#
|
|
#.#...# #.....#
|
|
###.### J L J #.#.###
|
|
#.....# O F P #.#...#
|
|
#.###.#####.#.#####.#####.###.#
|
|
#...#.#.#...#.....#.....#.#...#
|
|
#.#####.###.###.#.#.#########.#
|
|
#...#.#.....#...#.#.#.#.....#.#
|
|
#.###.#####.###.###.#.#.#######
|
|
#.#.........#...#.............#
|
|
#########.###.###.#############
|
|
B J C
|
|
U P P |