diff --git a/input/day16 b/input/day16 new file mode 100644 index 0000000..cc40574 --- /dev/null +++ b/input/day16 @@ -0,0 +1,141 @@ +############################################################################################################################################# +#.............#.......#...#...............#...........#.......................#...........#.............#.#.............#...#.....#........E# +#.#.#########.#.#####.#.###.#####.#######.#.#.###.###.#.#####.#.#.###.#.#####.#######.#.###.#.#.###.###.#.#.#.#####.###.#.###.###.#.#######.# +#.#.........#...#...#.#...#.....................#.#.........#.#...#...#...#.#...#...#.#.....................#.......#.#.#...#.#.#...#...#.#.# +###########.#####.###.###.#####.#.#.#######.#.###.#######.#.#.#########.#.#.###.#.#.#.#.#.###.#.###.###.#####.#####.#.#.###.#.#.#####.#.#.#.# +#...........#...#...#.#.....#...#.......#...............................#.....#...#.#.#...#.#.#.#.#...#.#...#.#.......#.#...#.........#...#.# +#.#########.#.#.#.#.#.#.#####.#######.#.#.#.###.#.#.#.#####.#########.#.###.#######.#.#####.#.#.#.#.#.#.#.#.#.#.#####.#.#.#####.###########.# +#.#.......#.#.........#.#.....#.....#...#.......#.#.#.....#.#...#.....#.#...#...#...#.#...#.#.#...#...#...#...#.....#...#.......#...........# +#.#.#####.###.#.#####.#.#.#########.#.###########.#.#####.#.###.#.#####.#.###.#.#.###.#.#.#.#.#.#.#.#########.#####.###########.#.#####.###.# +#...#...#...#.#.....#.#...........#.#.....#.#...#.#.#...#...#...#...#.....................#.#...#.#...........#...#.#.........#.#...#.....#.# +#.###.#.#.#.#.#####.#.###########.#.#.###.#.#.#.#.#.###.#####.#.###.###.#.#.#######.###.#.#.###.###.#####.#####.#.#.###.#.###.#.###.#.#.#.#.# +#...#.#.#.#.....#.....................#...#.#.#...#.....#.....#.#.#...#.......................#.#...#...#.#.....#.........#...#.#...#.#.#.#.# +#.###.#.#########.###.#.#######.#.###.#.###.#.#########.#.###.#.#.###.#.###.#.#####.#.#####.###.#.#.#.#.#.#.#####.###.#.#.###.###.###.#.###.# +#.#...#.......................#.#.#.....#...#...#.....#.#...#.#...#...#...#.#.....#.#...#...#...#.#.#.#.#.......#...#.#.#...#.#...#.#.#.#...# +#.#.###########.#.#.#.###.#.#.#.###.#.###.#.###.#.#.###.#####.###.#.#####.#.###.#.#.#.#.#####.###.#.#.#.#.#######.###.#.###.#.#.###.#.#.#.### +#.#.#.........#...#.#.....#.#.#.......#...#...#...#.#...#.....#...#.......#...#.#.#.#.#.#.....#...#...#.#.#.....#.....#.#...#...#...#.#...#.# +#.#.###.#.###.#####.#######.#.#.#####.#.#.###.###.###.###.#####.#############.#.#.#.###.#.#.###.###.###.###.###.#.#######.#.#####.#.#.#####.# +#.#.#.....#.............#...........#...#.#...#...#...#...#...#.#.....#.......#.#.#.....#.#.#...#.....#.....#...#.........#.#...#.#...#.....# +###.#.#.###.#.###.#####.###.###.#####.###.###.#.###.###.###.###.###.###.###.#####.#.#####.#.#.#####.#########.###########.###.#.###.#####.#.# +#...#...#...#...#.....#...#...#.#.....#.....#.#.#.......#...........#...#...#...#...#...#.#.#.....#.#.......#...#.....#...#...#...#...#...#.# +#.###.#.#.###.#.#####.###.###.#.#.#####.###.###.#.#####.#.#####.#####.#######.#.#####.#.#.#.#####.#.#.#.###.###.#.###.#####.#####.###.#.###.# +#...#.#.......#...#...#...#...#.#.#.....#.#.....#.#.....#.#...#.#.....#.......#.......#.#.....#...#...#...#...#.#...#.......#...#...#...#...# +#.#.###.#####.###.#.###.###.###.#.###.#.#.#######.#.#.#####.#.###.#####.###############.#.###.#.#######.#.#####.#.#.#########.#####.###.#.#.# +#...#.....#...#...#.#...#...#...#.....#...#...#...#.#.#.....#...#.....#.#...#.........#.#...#...#.....#.#.....#.....#.......#.....#...#...#.# +#.###.#.#.###.#.#.#.#.###.###.#.#########.#.#.#.###.#.#.#######.###.#.#.#.###.#######.#.#.#.#######.#.#.#####.#####.#.###.###.###.###.#.#.### +#...#...#...#.#.#.#.#.........#.........#.#.#.#.#...#.#.#.............#.#.#.......#...#...#.........#.#...#...#.....#.#...#...#.....#...#...# +#.#.###.###.#.#.#.#.###########.#######.#.#.#.#.#.###.#.###########.#.#.#.#.#####.#.#.#.#.###########.###.#.#.#.###.#.#####.###.#.#####.#.#.# +#.#.....#...#...#.#.......#.....#...#...#.#.#.#...#...#.........#.....#.#...#...#.#.#...#.#.......#...#.....#...#...#.........#.#.#...#.....# +#.#######.###.###.#######.###.#.#.#.#####.#.#.#.###.###########.#######.#####.#.#.#.###.#.#.#######.###.#########.#######.#####.###.#.#.#.#.# +#...#.....#.......#.....#...#...#.#.#.......#.....#...........#.#.......#.....#.#.#...#.#.#.......#.....#.......#...#...#...#...#...#.#...#.# +#.#.#.#######.#####.###.#.#.#####.#.#.#############.#########.#.#.#######.#####.#####.#.#.#.#####.###########.#.###.#.#.###.#.###.###.#.#.#.# +#...#...........#.....#.#.#...#...#...#.......#...#...#.......#...#...#.....#.#.#.....#.#.#.#.....#...........#.....#.#...#.#.#...#.....#.#.# +#.#.###########.#.#####.#.###.#.#######.#####.#.#.###.#.#####.#####.#.#.###.#.#.#.#.#####.#.#.###.#.#.###.#########.#.###.###.#.#########.#.# +#...#.......#...#...#...#.#...#.......#...#.#...#.....#.#...#...#...#.....#.#...#.#.#.....#.#.#...#.#...#.#.......#...#...#...#.....#.....#.# +#.###.#####.#.#.#.###.###.#.###.#########.#.#.#.#######.#.#.###.#.###.#####.#.###.#.#.#####.#.#####.#.#.###.#####.#####.###.#######.#.#.#.#.# +#.#.#.#.......#.#.#...#.....#...#.......#...#.#.#.......#.#.#...#.....#.....#.#...#.#...#.#.#.....#.#.#.......#...#...#.#.......#...#...#.#.# +#.#.#.###########.#.#####.#.#.#.#.#####.###.#.#.#.###.###.#.#.#########.#####.#.###.###.#.#.#####.#.#.###.#####.#.###.#.#######.#.###.###.#.# +#...#.......#.....#...#...#.#.#.#...#.#...#.#...#...#.#.#.#.#.........#...#...#...#...#.#.......#.#...#.....#...#.....#...#...#.#.#...#...#.# +###.#######.#.#######.#.###.#.#.###.#.###.#.#########.#.#.#.#########.###.###.###.###.#.#########.###.#.###.#.###.#######.#.#.#.#.###.#####.# +#...#...#...#...#.....#...#.#.#...#...#.#...#.........#.#.#.........#...#...#...#.#...#.........#.....#.#.#...#...#.....#.#.#...#...#.......# +#.#####.#.#####.#.#######.#.#.#.#.###.#.#######.#######.#.###.#.#######.#.#.#.#.#.#############.#######.#.###.#.###.#.#.#.#.###.###.#######.# +#.....#.#.#.....#.#.......#.#...#...#.#...#.....#.#.......#...#.#.......#.#.#...#...#...........#.....#.#.......#...#.#.#...#.#...#.......#.# +#####.#.#.#.#####.#####.#########.###.#.#.#.#.###.#.#######.#####.#######.#.#.#####.#.#########.#.###.#.#.#######.###.#######.###.###.###.#.# +#.....#.#...#...#.....#...........#...#.#...#.....#.#.....#...#...#.......#.#.......#.#...#...#...#.....#...#...#...#...........#.....#...#.# +#.#####.#####.#######.###########.#.#######.###.#.#.#.###.#.#.#.###########.#########.#.#.#.###.#.###########.#.###.#.###.#########.#.#.###.# +#.....#...#.#.......#.......#...#.#.......#...#.#.....#.#.#.#.#.....#...............#.#.#...#...#.....#...#...#...#.....#...........#...#.#.# +#####.#.#.#.#.#####.#######.#.#.#########.#.#.#.#####.#.#.#.#.#####.#.###.#.#######.#.#.#####.#######.#.#.#.#.###.#####.#############.###.#.# +#.....#.#...#.#...#.......#...#.........#.#.#.....#.......#.#.....#.#.#...#.#.....#.#.#...#...#...#...#.#...#...#.......#...........#.#.....# +#.#####.#.###.#.#########.###########.###.#.#.###.#####.#.#.#.#.###.#.#.###.###.#.#.#.#.#.#.###.#.#.###.#######.###############.###.#.#####.# +#.........#...#.........#...........#...#.#.....#.....#.....#.#.#...#.#...#.....#.#.#.#.#.......#.#...#.......#.................#...#.....#.# +#.###.#.#.#.#.#.#######.#####.###.#.###.#.###.#######.#######.###.###.###.#########.#.###############.#######.#.#######.#############.###.#.# +#...#...#...............#...#...#...#...#...#.#.....#...#...#.........#.......#.....#.#.............#.....#...#.......#.#...#...#.........#.# +###.#.###.###.###.#######.#.###.###.#.#####.###.###.#.#.#.#.###.#############.#.#.###.#.###########.#.###.#.#########.###.#.#.#.#.###.#####.# +#.#.#...#.#.......#...#...#...#...#.#.....#.....#.#.#.#...#...#.#.......#...#.#.#.#...#.#.......#...#.#.....#...#.....#...#.#.#...#.....#...# +#.#.#.#.#.#.#.#####.#.#.#####.###.#.#####.#######.#.#.#######.#.#.#####.#.###.#.###.###.#######.#.#####.###.#.#.#.#####.###.#.#####.#.###.### +#...#.#...#.#.......#...#...#.....#.#...#.......#...#...#...#.#.#.....#.#.....#...#.#.........#.........#...#.#.#...#...#.#...#...#.......#.# +#.###.#.#.#.#.###.#######.#.#######.#.#.#######.#.#####.###.#.#######.#.#.###.###.#.###.#####.#######.###.###.#.###.#.###.#####.#.#.#.#####.# +#.#.......#...#.........#.#.......#.#.#.....#.....#.#...#.......#...#.#.#...#.#...#...#.#...#.......#.#...#...#...#.#.#.........#.#...#...#.# +#.#####.#.###.#.#######.#.###.#.###.#.#.###.#.#####.#.###.#.###.#.#.#.#.#.#.#.#.#####.#.###.#######.###.#####.###.#.#.#.#####.###.###.#.#.#.# +#.....#...#...#.......#.#...#.#.#...#.#.#...#...#.#...#...#.#...#.#...#...#.#.#.....#.#...#.......#.....#.....#...#.#.......#...#...#...#...# +#####.#.###.#####.###.#.#.###.#.#.#####.#.###.#.#.#.#####.#.#.#.#.#########.#.#####.#.###.#####.#.###.#.#.#####.###.#######.#######.#.#####.# +#...#.#...#.....#...#.#.#.....#.#.#.....#.....#.#...#.....#.#...#...#.#...#.#...........#.....#.#...#...#.#.........#.......#...........#...# +#.###.#.#######.#####.###.#.#####.#.###########.###.#.#.#####.#####.#.#.#.#.#.#########.#####.#.#.#.#####.#.#########.#######.###########.### +#.#...#.........#...#.#...#...#...#.#.....#...#...#.#.#.#.....#...#...#.#.#.#.#...#.....#...#...#.....#...#.#...#.....#.#.................#.# +#.#.###.#########.#.#.#.#####.#.###.#.###.#.#####.#.###.#.###.#.#.#.###.#.#.###.#.#.#######.###.#####.#.###.#.#.#.#####.#.#.###.###########.# +#.#.....#.........#...#.#.....#...#.#...#.#.......#.....#...#.#.#...#...#...#...#...#.......#.......#...#.#...#.#.#.....#.#...#.....#.......# +#.#####.#.###.###.#####.#.###.###.#.###.#.#####.###########.###.#####.###.#.#.#######.#.#####.###.#.#####.#.#.###.#.#.###.###.#####.#.####### +#...#.....#...#...#...#.#...#...#.#.#.........#.............#...#...#...#.#.#.........#.....#.#.#.#...#.....#.....#.#.....#...#.#...#.......# +#.#.#.#.###.#.#.###.#.#.###.#####.#.#.#.#####.#.###.#######.#.###.#.###.#.#.#.#.###########.#.#.#.###.#.#.###.#####.#######.#.#.#.#########.# +#.#...#.....#...#.#.#...#.#.......#.#...#...#...#.....#.....#.#...#.#...#...#.#...........#.....#.#...#...#...#.....#.....#.#.#.#...........# +#.#####.#####.###.#.###.#.#########.###.###.###.#.###.###.#.#.###.###.#######.#################.#.###.###.#.###.#####.###.#.#.#.###########.# +#.....#...#.#.....#.....#.....#...#...#.#.....#...#.#.#.....#.#...#.........#.........#...#...#.#.......#.#...#.#.#...#.#.#.#.#...........#.# +#####.###.#.#.###.#####.###.#.#.#.#.#.#.#.#.#.#####.#.#.#.#.#.#.#.#.#######.#.###.#.#.#.#.#.#.#.#####.#.#.###.#.#.#.###.#.#.#.###.#########.# +#.....#...#.....#.....#.....#.#.#...#.#...#.#.....#.#...#.....#.#.#.....#...#...#...#...#...#.#...#...#.....#.#...#.#.#...#...#...#.........# +#.###.#.###.#.#.#.###########.###.###.#####.#####.#.#####.#.#.#.#.#####.#.###########.###.###.#####.###.#####.#.###.#.#.###.#.#.#.#.######### +#.#.....#.....#...#.......#.#...#...#.......#...#.......#.#.#...#.#...#.#.#.................#.....#.#.....#...#.#...#...#...#...#.#...#.....# +#.#.#.###.#.#.###.#.###.#.#.###.###.###.###.#.#.#####.###.#.###.###.#.#.#.#.#######.#######.#####.#.#.#####.###.#.###.#####.#####.###.#####.# +#.#.#.#.....#...#.#.#.#.#.#...#...#...........#...#...#...#...#.#...#...#.#...#.....#.....#.......#...#.#...#...#.#.#.#.....#...#.....#...#.# +#.#.###.###.#.#.###.#.#.#.###.###.###.###.#######.#.###.#######.#.###.###.###.#######.###.#########.###.#.###.###.#.#.#.#####.#.#.###.#.#.#.# +#.#.......#.....#.....#.#.#...#...#...#...#...#...#.#.#.........#...#.#...#...#.......#.#.#.......#.....#.#...#...#.....#...#.#.#.....#.#...# +#.#######.#.#.###.#####.#.#.#.#.###.#######.#.#.###.#.#############.###.###.###.#######.#.#.#.###.#######.#.###.#########.#.#.#.#.###.#.###.# +#.#.#...#.#.........#...#.#.#.#.#...........#.#...#.#.............#...#...#.............#.#.#...#.........#...#...#.....#.#...#.#...#.#.#...# +#.#.#.#.###.#.#######.###.#.#.#.#######.#.###.#####.###.#######.#####.###.#####.#########.#.###.###########.#####.#.###.#.#####.#.#.#.#.##### +#...#.#...#.....#.....#.#...#.#.......#.#...#...........#.......#.......#.....#.#...#.....#.#.#.#.#...#...#.#.....#.#.....#.....#.#.#.#.....# +#####.###.#.#.###.#####.#####.#######.#.###.#######.#############.#####.#####.###.#.#.#####.#.#.#.#.#.#.#.#.#.#####.#.#####.#####.#.#.#.###.# +#.....#.#.#.......#.........#...#...#.........#...#.........#...#.....#.....#...#.#...#.....#.#...#.#...#...#.....#...#...#.................# +#.#####.#.#.#.#.#########.#####.#.#.#.#####.#.###.#.#######.#.#.#.###.###.#.###.#.#########.#.#.#.#.#############.###.###.#####.#.#####.#.### +#...#.#...#...#.#.......#.........#.#.....#.......#.......#...#.#...#.#...#...#.#.#.......#...#.#.#.#...............#.#.....#.#.#.#...#.#...# +###.#.#.###.#.#.#.#####.###########.#####.#######.#######.#.###.###.#.#.###.#.#.#.#.###.#.#####.#.#.#.#.#############.#.###.#.#.#.#.#.#####.# +#...#...........#.#...#...#...#.........#...#...#...#...#.#...#...#.#.#.....#.#...#.#...#.#.....#...#...........#...#...#.....#.#...#.....#.# +#.#####.###.#.#.#.###.###.#.#.#############.#.#.#.###.#.#.###.###.###.###.###.#######.###.#.#####.#############.#.#.#####.#.#.#.#.#######.#.# +#.#...#...#.#.#.#...#...#...#.#.....#.....#.#.#.#.#...#...#.....#.....#.....#.#.......#.#...#.....#.....#...#.#...#.......#.#.#.........#...# +#.#.#.###.#.#.#.###.#.###.###.#.###.#.###.#.###.#.#.#######.###########.###.#.#####.###.#####.#####.###.#.#.#.#########.###.#.###.###.#####.# +#...#.#.#.....#.#...#.....#...#...#.#.#.#.....#...#.....#...............#.#.#.......#.......#.......#.#...#.#.........#.....#.#...#.#.#.....# +#.###.#.###.###.#.#####.#.#.#.#.#.#.#.#.#.###.#####.###.#.#############.#.#.#########.#.###.#########.#####.#.#####.#########.#.###.#.#.##### +#...#.#...#.....#...#...#...#.#...#.#.#.#...#.#...#.#...#.#.........#...#.........#...#.#...#...#.....#.....#...#.#...#.......#...#...#.#...# +###.#.###.#.#######.#.###.#.#.###.#.#.#.###.#.#.#.###.###.#.#.###.###.#######.###.#####.#.###.###.###.#.#.#####.#.###.#.###.#####.###.#.#.### +#.#.#...#.........#.#.#.....#.....#.......#.#...#.....#.....#.#.#.#.........#...#...#...#.#.....#...#...#.....#.......#.#.#.....#.#.....#...# +#.#.###.#########.#.#.#.#######.#.#########.###############.#.#.#.#.###.###.#.#####.#.###.#####.###.#####.###.###.###.#.#.#.#.#.#.#.#.#####.# +#.#.#.#.#...#...#.#.......#...#.#.....#.....#.............#.#...#.#.......#.#.......#.#.......#...#.#.#.....#.#...#.........#.......#.....#.# +#.#.#.#.#.#.#.#.#.#.#####.#.#.#.#.#####.###.#.#.#########.#.#####.#########.#.#######.#######.#.###.#.#.#.#.#.#####.#.#####.#.#######.###.#.# +#.#.#.#...#.#.#.#.#.....#...#.#...#.....#...#.#...#.................#...#.......#.....#...#.....#...#.....#.#...#...#...#...#.#.......#.....# +#.#.#.#####.###.#.#.###.#####.#####.#####.#.#####.#.###############.#.#.#.#####.#.#.###.#.#####.#.#######.#.###.#.#######.###.#.#####.#####.# +#.........#.#...#.#.#.......#...#.#...#...........#...#...#.........#.#...#...#.#.#.....#.....#.#.....#...#.#...#.....#.....#.#.#...#...#.#.# +#.#########.#.###.#.#.#####.###.#.###.#####.#####.#.#.#.#.#######.###.#####.###.###########.#.#.#####.#####.#.#####.#.#.#####.#.#.#.#.#.#.#.# +#...........#.....#.#.#...#...#.#.........#.....#.......#.#.....#.#.#.#...#...............#.#.#.#...#.....#.#.....#.#.....#...............#.# +#####.#.#.###.#######.#.#.#.###.###.#####.###.#.###.#####.#.###.#.#.#.#.#.#.#############.###.#.###.#####.#.#.###.#########.###.#.###.#.#.#.# +#...#.#.#.#...........#.#...#...#...#...#.....#.......#.....#.#.#...#.#.#...#.....#...#...#...#.........#...#.....#...#...#.....#...#...#...# +#.#.#.#.#.#############.#####.###.#.###.###.#####.###.#######.#.#####.#####.#.###.###.#.###.#################.#####.#.#.#.#######.#.#.#####.# +#.#...#...#.....#...#...#.....#...#.....#...#.......#...#.....#...#...#...#.#.#.#...#...#...#...............#.......#...#.......#.#.......#.# +#.#######.#.###.#.###.###.#######.#####.#.#.#.#.#######.#.#.#####.#.###.#.#.#.#.###.#.###.###.###########.#####################.###.#####.### +#.....#...#...#.#.....#...#.......#...#...#.#.#.#.......#.#.........#...#.#.#...#...#.....#...#.....#...#.#...............#...#...#.#...#...# +#.###.###.###.#.#######.###.#######.#.#####.###.#.#.#####.###########.###.###.#.#.#.#####.#.###.###.#.#.#.#.#######.#####.#.#.###.#.###.###.# +#...#.....#...#.........#...........#.....#.....#.#.#...#...#...#...#...#...#...#.#.#...#.#.#...#.#...#.#...#.....#...#.....#...#.#.....#...# +###.#####.#.#############.#.#.#####.#.#########.#.###.#.###.#.#.#.#.###.###.#.###.#.#.#.###.#.###.#####.#####.#.#.###.#######.###.#####.#.### +#...#...#.#.#.....#.....#...#.....#.#.#...#.....#.#...#.#.#.#.#.#.#...#...#.#.#...#.#.......#...#...#.....#...#.#...#.....#...#...#.....#...# +#.#####.#.#.#.###.#.#.#.#.#####.###.#.#.#.#.###.#.#.###.#.#.#.#.#.#.#.#.#.#.#.#.#####.#########.#.###.#####.###.###.#####.#.###.#######.###.# +#.#...#.#.#.#.#.#...#.#.#...........#.#.#...#.#...#.#.#.#.....#.#...#...#.#.#.#.....#.#.....#.....#...#.......#...#.#...#.#...#.#.....#.#...# +#.#.#.#.#.#.#.#.#####.#.#.#.#.#########.#####.#.###.#.#.###########.###.#.#.#.###.#.#.#.###.#######.#.#.#########.#.###.#.#####.###.#.###.#.# +#...#...#...#.......#.#.#.#.#.#...#.....#.....#.#...#.#.......#.....#...#.#...#...#...#.#.#.#.....#.#...#.....#...#.#...#.#...............#.# +#######.#.#########.#.#.#.###.#.#.#.#####.###.#.#.###.#######.#.#####.###.#####.#.#####.#.#.#.###.#.#.###.###.#.###.#.#.#.#.#.###.#####.#.#.# +#.#.....#...#.....#.#.#...#...#.#...#.....#...#...#.........#...#...#.....#.....#.....#.#.#...#.#...#...#...#...#.#...#.#.#.#.....#...#...#.# +#.#.#####.#.#.###.#.#.#####.###.#####.###.#.#######.#############.#.#######.#####.###.#.#.#####.###.###.###.#####.#####.#.#.#.#.#.#.#####.#.# +#.#.#.....#...#.#.........#.....#.#...#...#.#.......#.............#.#.....#.#...#...#...#.......#...#.....#.......#.....#...#.......#.....#.# +#.#.#.#.#.#####.#######.#.#.#####.#.###.###.###.###.#.#####.#######.#.###.###.#.###.#####.#.#####.###.#.#######.#.#.###########.#.###.###.#.# +#...#.#.....#...........#.#...#.#.....#.#.....#...#.......#...#...#...#...#...#...#.#.#...#.#.....#...#.........#...#...........#.....#...#.# +#.#######.#.###.#.#####.#.###.#.#.###.#.#####.#.#.###########.#.#.#####.#.#.#####.#.#.#.#.###.#####.###.#.#.#####.###.#####.###.#.#####.#.#.# +#.......#.#...#.#.#...#.#...#.#...#...#.#...#.#.#.......#.....#.#.....#...#.#...#.#.#...#.....#.....#...#.....#...#.....#...#...#...#...#...# +#######.#####.#.#.#.###.#.#.#.#.#####.#.#.#.#.#.#######.#.#####.#.#######.#.#.#.#.#.#########.#.#.#####.###.#.#.#####.###.#.#.#.###.#.###.### +#.....#.#...#.#.#.#.....#.#.............................#.#...#.#.#.......#.#.#...#...#.......#.........#.#...#.#.....#...#...#...#.#.....#.# +#####.#.#.#.#.#.#.###.###.#.#.###.#.#.#####.###.#.#######.#.#.#.#.#.#####.#.#.#####.#.#.#####.#.#.#.###.#.#.###.###.#.#.###.###.#.#.#####.#.# +#.....#...#...#.#...#.#...#.#.#...#.#.#.....#...#.....#.....#.#.#...#.......#.....#.#...#...#...#.....#.#.#.#.......#...#...#...#.#.#.....#.# +#.###.#########.###.#.#.###.#.###.#.#.#.#####.#.#####.#######.#.#####.###.#######.#.#####.#.#.###.#.#.#.#.#.#########.###.#.#.#.###.###.#.#.# +#.#.#.......#...#...#...#.#.#...#...#.#.#.#...#.....#.#.......#.....#.#.......#.#.#.......#.#.....#.#.#...#...#.......#.......#...#.....#...# +#.#.###.#####.###.#######.#.###.#####.#.#.#.###.###.#.#.###########.#.#.#.###.#.#.###########.###.#.#.###.#.#.#.###.###.###.###.#.#.#####.#.# +#.#.....#...#.#.#.#...........#.#.....#.#...#.....#.#...#.......#...#...#...#.#...............#...#.#...#...#.#...#.#...#...................# +#.###.###.#.#.#.#.#######.###.#.#######.#.#####.#.#.#####.#####.#.#####.#.#.#.###############.#.#.#.###.###.#.###.#.#.#####.###.###.#.#.#.#.# +#...#.#...#...#.#.......#.#.....#.......#.......#.................#...#.....#...#.....#.........#.....#.......#...#.#.#.....#...#...#.#.#...# +#.#.###.#######.#######.###.#.###.#############.#.#########.#####.#.#.###.#####.#.###.#.###.#####.#.#######.###.###.#.#.#####.#.###.#.#.#.### +#S#...................#...........#.......................#.........#...........#...#.....#.......................#.....#...........#.......# +############################################################################################################################################# diff --git a/src/day16.scala b/src/day16.scala new file mode 100644 index 0000000..7c453f9 --- /dev/null +++ b/src/day16.scala @@ -0,0 +1,71 @@ +package aoc +package day16 + +import scala.collection.{mutable => m} + +val dayNumber = "16" + +@main def part1: Unit = + println(part1(loadInput(dayNumber))) + +@main def part2: Unit = + println(part2(loadInput(dayNumber))) + +def part1(input: String): String = + val maze = input.split("\n") + maze.findLowestCost.toString + +def part2(input: String): String = + "" + +type Pos = (Int, Int) +extension (pos: Pos) + def x = pos._1 + def y = pos._2 + def +(dir: Dir): Pos = pos + dir.change + def +(offset: Pos): Pos = (pos.x + offset.x, pos.y + offset.y) + def abs: Pos = (Math.abs(pos.x), Math.abs(pos.y)) + def neighbors(curDir: Dir): Array[(Pos, Dir, Int)] = + Dir.values.map(d => (pos + d, d, curDir.rotationCost(d) + 1)) + +enum Dir(val change: Pos): + case Up extends Dir(0 -> -1) + case Right extends Dir(1 -> 0) + case Down extends Dir(0 -> 1) + case Left extends Dir(-1 -> 0) +import Dir.* + +extension (dir: Dir) + def rotationCost(to: Dir): Int = + (dir.change + to.change).abs match + case (0, 0) => 2000 + case (2, 0) | (0, 2) => 0 + case _ => 1000 + +type Maze = Array[String] +extension (maze: Maze) + def indices = for + x <- maze.head.indices + y <- maze.indices + yield (x, y) + + def findPos(c: Char): Pos = indices.find((x, y) => maze(y)(x) == c).get + def getPos(pos: Pos): Char = maze(pos.y)(pos.x) + + def findLowestCost: Int = + val start = findPos('S') + val end = findPos('E') + val visited = m.Map.empty[(Pos, Dir), Int] + val q = m.Queue((start, Right, 0)) + while q.nonEmpty do + val (pos, dir, cost) = q.dequeue + val prevCost = visited.get(pos -> dir) + if prevCost.forall(_ > cost) then + visited.update(pos -> dir, cost) + q.enqueueAll( + pos.neighbors(dir).collect { + case (nPos, dir, nCost) if getPos(nPos) != '#' => + (nPos, dir, nCost + cost) + } + ) + visited.view.filterKeys(_._1 == end).values.toList.sorted.head