2023 Working on day 23

This commit is contained in:
Brian Buller 2023-12-23 16:03:45 -06:00
parent 89bb8f2bb8
commit f5ce895221
4 changed files with 327 additions and 0 deletions

141
2023/day23/input Normal file
View File

@ -0,0 +1,141 @@
#.###########################################################################################################################################
#...#...#.........#...#...#.......#...#.....#...#...#.....###...#.........#.......#...###...#####.....#.......#.....#...#.......#.......#...#
###.#.#.#.#######.#.#.#.#.#.#####.#.#.#.###.#.#.#.#.#.###.###.#.#.#######.#.#####.#.#.###.#.#####.###.#.#####.#.###.#.#.#.#####.#.#####.#.#.#
#...#.#.#...#.....#.#...#.#...#...#.#.#...#.#.#.#.#.#...#...#.#.#.....#...#.....#.#.#...#.#...#...#...#.....#.#...#.#.#.#...#...#.#.....#.#.#
#.###.#.###.#.#####.#####.###.#.###.#.###.#.#.#.#.#.###.###.#.#.#####.#.#######.#.#.###.#.###.#.###.#######.#.###.#.#.#.###.#.###.#.#####.#.#
#...#.#.#...#.....#...#...#...#.#...#.>.>.#.#.#.#.#.###.#...#.#...#...#...>.>...#...#...#.#...#...#.#.......#.....#.#.#...#.#...#.#.......#.#
###.#.#.#.#######.###.#.###.###.#.#####v###.#.#.#.#.###.#.###.###.#.#######v#########.###.#.#####.#.#.#############.#.###.#.###.#.#########.#
###...#.#.#.......#...#...#...#.#.#...#...#...#...#...#.#...#.#...#.......#.....#.....#...#...#...#.#.....#.......#.#.#...#.###...#...#...#.#
#######.#.#.#######.#####.###.#.#.#.#.###.###########.#.###.#.#.#########.#####.#.#####.#####.#.###.#####.#.#####.#.#.#.###.#######.#.#.#.#.#
#...###.#.#.#####...#.....#...#...#.#.#...#...........#...#.#.#...###...#...#...#...###.#.....#...#.....#...#...#.#...#.....#.......#...#.#.#
#.#.###.#.#v#####.###.#####.#######.#.#.###.#############.#.#.###.###.#.###.#.#####.###.#.#######.#####.#####.#.#.###########.###########.#.#
#.#.....#.#.>.#...###...#...#.......#.#...#.....#...#...#.#.#.#...#...#.#...#...###.#...#...#...#.#.....###...#...###.......#...........#.#.#
#.#######.#v#.#.#######.#.###.#######.###.#####.#.#.#.#.#.#.#.#.###.###.#.#####.###.#.#####.#.#.#.#.#######.#########.#####.###########.#.#.#
#...#...#.#.#...#...###.#.###.......#...#...#...#.#.#.#.#.#.#.#.>.>.###...#...#...#.#...#...#.#.#.#.###...#.#...#...#.....#.............#...#
###.#.#.#.#.#####.#.###.#.#########.###.###.#.###.#.#.#.#.#.#.###v#########.#.###.#.###.#.###.#.#.#.###.#.#.#.#.#.#.#####.###################
###...#...#.......#.#...#.#.........###.#...#...#.#...#...#.#.###...#...#...#.....#.....#...#.#...#.>.>.#.#...#...#.....#.#...........#.....#
###################.#.###.#.###########.#.#####.#.#########.#.#####.#.#.#.#################.#.#######v###.#############.#.#.#########.#.###.#
###...#...#.........#.....#.......#...#.#.#.....#.#.....###...#...#.#.#...#...#...###...###...#.......###...#...#.......#...#...#...#.#.#...#
###.#.#.#.#.#####################.#.#.#.#.#.#####.#.###.#######.#.#.#.#####.#.#.#.###.#.#######.###########.#.#.#.###########.#.#.#.#.#.#.###
#...#...#.#...............###...#...#.#.#.#.....#.#...#.#...#...#...#.....#.#...#...#.#.#...###...#.......#.#.#.#...#.........#...#...#.#...#
#.#######.###############.###.#.#####.#.#.#####.#.###.#.#.#.#.###########.#.#######.#.#.#.#.#####.#.#####.#.#.#.###.#.#################.###.#
#.......#.....#...........#...#.......#...#.....#.#...#...#...#.......###...#...#...#.#.#.#.#####.#.#.....#...#.#...#...................#...#
#######.#####.#.###########.###############.#####.#.###########.#####.#######.#.#.###.#.#.#.#####.#.#.#########.#.#######################.###
###.....#...#...###.......#...#...#...#...#.....#.#.....#...#...#.....#.....#.#.#...#.#...#.....#...#.......###...###.................#...###
###.#####.#.#######.#####.###.#.#.#.#.#.#.#####.#.#####.#.#.#.###.#####.###.#.#.###.#.#########.###########.#########.###############.#.#####
#...#.....#.....#...#.....###.#.#...#...#...#...#.#.....#.#.#.#...#.....#...#.#.###.#.#.........#...........#...#...#.........#.....#...#...#
#.###.#########.#.###.#######.#.###########.#.###.#.#####.#.#.#.###.#####.###.#.###.#.#.#########.###########.#.#.#.#########.#.###.#####.#.#
#.....#.........#.#...###...#...#...#...#...#.....#.....#.#...#...#.....#...#.#...#...#.......###.........###.#...#.#...#...#...#...#...#.#.#
#######.#########.#.#####.#.#####.#.#.#.#.#############.#.#######.#####.###.#.###.###########.###########.###.#####.#.#.#.#.#####.###.#.#.#.#
#.......#...#...#.#.#...#.#.#.....#...#.#...#...........#.#.......#...#.#...#...#.#...###.....#...#.......#...#...#.#.#...#.....#.....#...#.#
#.#######.#v#.#.#.#.#.#.#.#.#.#########.###.#.###########.#.#######.#.#.#.#####.#.#.#.###v#####.#.#.#######.###.#.#.#.#########.###########.#
#.........#.>.#.#.#...#...#.#.........#.#...#...#.....#...#...#...#.#.#.#.#...#.#...#...>.>...#.#.#...#...#...#.#...#.........#.......#...#.#
###########v###.#.#########.#########.#.#.#####.#.###.#.#####.#.#.#.#.#.#.#.#.#.#########v###.#.#.###.#.#.###.#.#############.#######.#.#.#.#
#...#.......###.#.#.........#.........#...#...#...###.#.....#.#.#.#.#.#.#.#.#.#.#.........###.#.#...#...#.#...#...#...#.....#.......#...#.#.#
#.#.#.#########.#.#.#########.#############.#.#######v#####.#.#.#.#.#.#.#.#.#.#.#.###########.#.###.#####.#.#####.#.#.#.###.#######.#####.#.#
#.#...#...#...#...#.#.......#.......#...###.#.#.....>.>.....#...#.#.#.#.#.#.#.#.#...#...#...#...#...#.....#...#...#.#.#...#.#.......#...#...#
#.#####.#.#.#.#####.#.#####.#######.#.#.###.#.#.#####v###########.#.#.#.#.#.#.#.###.#.#.#.#.#####.###v#######.#.###.#.###.#.#v#######.#.#####
#.......#.#.#.#...#.#...#...#.......#.#.....#.#...#...#...#.....#.#.#.#.#.#.#.#.#...#.#...#...#...#.>.>.#...#.#...#.#.#...#.>.#...###.#...###
#########.#.#.#.#.#.###.#.###.#######.#######.###.#.###.#.#.###.#.#.#.#.#.#.#.#.#.###.#######.#.###.#v#.#.#.#.###.#.#.#.#####v#.#.###.###.###
###...#...#.#.#.#.#...#.#.###.......#.......#.#...#.#...#.#.#...#...#.#.#.#.#.#.#.....#.....#.#.#...#.#...#...###.#.#.#...#...#.#...#...#...#
###.#.#.###.#.#.#.###.#.#.#########.#######.#.#.###.#.###.#.#.#######.#.#.#.#.#.#######.###.#.#.#.###.###########.#.#.###.#.###.###.###.###.#
#...#...#...#.#.#...#.#.#...#...#...#...#...#.#.#...#.#...#.#.#...###...#...#...#.......###...#...###...........#.#.#.#...#...#.#...#...#...#
#.#######.###.#.###.#.#.###.#.#.#v###.#.#.###.#.#.###.#.###.#.#.#.###############.#############################.#.#.#.#.#####.#.#.###.###.###
#.#...#...###...#...#.#.###.#.#.>.>...#.#...#.#.#.#...#.....#...#...#...###.....#.......#...###.................#...#.#...#...#.#.....#...###
#.#.#.#.#########.###.#.###.#.###v#####.###.#.#.#.#.###############.#.#.###.###.#######.#.#.###.#####################.###.#.###.#######.#####
#.#.#.#...#.......###...#...#.###.#...#...#.#.#.#.#.#.........#...#...#...#...#...#...#...#...#...........#...#.....#.....#.....#.....#.....#
#.#.#.###.#.#############.###.###.#.#.###.#.#.#.#.#.#.#######.#.#.#######.###.###.#.#.#######.###########.#.#.#.###.#############.###.#####.#
#...#.....#.............#.....#...#.#...#.#.#.#.#...#.......#.#.#.......#...#...#...#.........#...........#.#.#.#...###...#.......###...#...#
#######################.#######.###.###.#.#.#.#.###########.#.#.#######.###.###.###############.###########.#.#.#.#####.#.#.###########.#.###
#.......................#.....#...#.#...#...#...#.......#...#...###...#.....###...#...........#...#...#.....#...#.......#.#.......#...#...###
#.#######################.###.###.#.#.###########.#####.#.#########.#.###########.#.#########.###.#.#.#.#################.#######.#.#.#######
#.................#...###...#.....#.#.......#...#.....#...#...###...#...###...###...###.....#...#...#.#.#.................#.......#.#.###...#
#################.#.#.#####.#######.#######.#.#.#####.#####.#.###.#####.###.#.#########.###.###.#####.#.#.#################.#######.#.###.#.#
#.............#...#.#...###.......#.#.......#.#.#...#.......#...#.....#...#.#.#...#...#.###...#.....#.#.#.......#...###...#.........#.....#.#
#.###########.#.###.###.#########.#.#.#######.#.#.#.###########.#####.###.#.#.#.#.#.#.#.#####.#####.#.#.#######.#.#.###.#.#################.#
#...........#.#...#...#.#...###...#.#...#...#.#.#.#.#...........#...#.#...#.#.#.#.#.#.#.#...#.......#...#...#...#.#.#...#.....#...........#.#
###########.#.###.###.#.#.#.###v###.###.#.#.#.#.#.#.#.###########.#.#.#.###.#.#.#.#.#.#v#.#.#############.#.#.###.#.#.#######.#.#########.#.#
#...........#.....###.#.#.#.#.>.>.#.#...#.#.#.#.#.#.#.....#.....#.#.#.#.#...#...#...#.>.>.#.....#...###...#...###.#...#.......#.........#.#.#
#.###################.#.#.#.#.#v#.#.#.###.#.#.#.#.#.#####.#.###.#.#.#.#.#.#############v#######.#.#.###.#########.#####.###############.#.#.#
#.......#...#.....#...#.#.#...#.#...#...#.#.#.#.#.#.#...#.#...#...#.#.#.#.#...........#.#...###...#...#.........#.#.....#...#...#.......#...#
#######.#.#.#.###v#.###.#.#####.#######.#.#.#.#.#.#.#.#.#v###.#####.#.#.#.#.#########.#.#.#.#########.#########.#.#.#####.#.#.#.#v###########
#...###...#.#...#.>.###...#...#.....#...#.#.#.#.#.#...#.>.>.#.....#...#.#.#.........#...#.#.......#...#.........#.#.#...#.#.#.#.>.#...###...#
#.#.#######.###.#v#########.#.#####.#.###.#.#.#.#.#######v#.#####.#####.#.#########.#####.#######.#.###.#########.#.#.#.#.#.#.###v#.#.###.#.#
#.#.#.....#.#...#...#.......#.......#.#...#.#.#...#.....#.#.....#.....#...#.......#...###.#.....#...###.......#...#...#.#.#.#...#.#.#...#.#.#
#.#.#.###.#.#.#####.#.###############.#.###.#.#####.###.#.#####.#####.#####.#####.###.###.#.###.#############v#.#######.#.#.###.#.#.###.#.#.#
#.#.#...#.#...#...#.#.....#.........#.#.###...#...#...#.#.....#.......#.....#...#...#...#.#.#...#...#.......>.>.#...###...#.#...#...###...#.#
#.#.###.#.#####.#.#.#####.#.#######.#.#.#######.#.###.#.#####.#########.#####.#.###.###.#.#.#.###.#.#.#######v###.#.#######.#.#############.#
#.#.....#...#...#.#.###...#.#.......#...#.......#.....#.#...#.....#...#.......#...#...#.#.#.#.#...#...#.....#...#.#.#...###...#...#.......#.#
#.#########.#.###.#.###.###.#.###########.#############.#.#.#####.#.#.###########.###.#.#.#.#.#.#######.###.###.#.#.#.#.#######.#.#.#####.#.#
#.........#...###.#.#...#...#.........###.......#.....#...#.......#.#.###...#...#...#.#.#.#.#.#.#...#...#...#...#.#...#.....###.#.#.....#.#.#
#########.#######.#.#.###.###########.#########.#.###.#############.#.###.#.#.#.###.#.#.#.#.#.#.#.#.#.###.###.###.#########.###.#.#####.#.#.#
#.....###...#...#...#.....###.......#.#.........#.###.......###...#.#.#...#...#.....#...#...#...#.#...###.....###.#.......#.#...#.#.....#...#
#.###.#####.#.#.#############.#####.#.#.#########.#########.###.#.#.#.#.#########################.###############.#.#####.#.#.###.#.#########
#...#.#...#...#...###...#.....#...#...#.......#...#.........#...#.#.#.#.....#...###...#...###...#.....#...###.....#.....#...#...#.#.........#
###.#.#.#.#######.###.#.#.#####.#.###########.#.###.#########.###.#.#.#####.#.#.###.#.#.#.###.#.#####.#.#.###.#########.#######.#.#########.#
###.#.#.#.#.....#...#.#...#.....#...#...#...#...###.....#...#...#.#.#.#...#.#.#...#.#.#.#.#...#.#.....#.#...#.....#.....#.....#.#...#.....#.#
###.#.#.#.#.###.###.#.#####.#######.#.#.#.#.###########.#.#.###.#.#.#.#.#.#v#.###.#.#.#.#.#.###.#.#####.###.#####.#.#####.###.#.###.#.###.#.#
#...#...#.#...#...#.#.#.....#.......#.#.#.#.....#.......#.#...#.#.#.#.#.#.>.>.#...#.#.#.#.#...#.#...###.#...#...#.#.#...#.#...#.#...#...#.#.#
#.#######.###.###.#.#.#.#####.#######.#.#.#####.#.#######.###.#.#.#.#.#.###v###.###.#.#.#.###.#.###v###.#.###.#.#.#.#.#.#.#.###.#.#####v#.#.#
#.#.....#.....###...#...#.....###.....#.#...#...#.....#...#...#.#.#.#.#.###...#.....#.#.#.#...#...>.>...#...#.#.#.#.#.#.#.#...#.#.#...>.#...#
#.#.###.#################.#######.#####.###.#.#######v#.###.###.#.#.#.#.#####.#######.#.#.#.#######v#######.#.#.#.#.#.#.#.###.#.#.#.###v#####
#...###.........#.......#.#.....#.....#.#...#.#...#.>.>.###.....#.#.#...#...#...#...#...#.#.#.......#.....#.#.#.#.#.#.#.#...#.#.#.#.###.....#
###############.#.#####.#.#.###.#####.#.#.###.#.#.#.#v###########.#.#####.#.###.#.#.#####.#.#.#######.###.#.#.#.#.#.#.#.###.#.#.#.#.#######.#
#...............#...#...#...#...###...#.#.###.#.#...#...###.....#...###...#.....#.#.....#.#.#.....#...#...#...#.#.#.#.#...#.#...#.#.#.......#
#.#################.#.#######.#####.###.#.###.#.#######.###.###.#######.#########.#####.#.#.#####.#.###.#######.#.#.#.###.#.#####.#.#.#######
#...#...#...###...#.#.....#...#.....#...#.###...#.......#...#...###...#.#...#...#.#.....#...#.....#.#...###...#.#.#...###.#.#.....#.#.......#
###.#.#.#.#v###.#.#.#####.#.###.#####.###.#######.#######.###.#####.#.#.#.#.#.#.#.#.#########.#####.#.#####.#.#.#.#######.#.#.#####.#######.#
###...#...#.>.#.#.#...#...#...#.....#...#...#.....#...#...###.......#.#.#.#.#.#...#.........#...#...#.......#.#...###.....#.#.#.....#.......#
###########v#.#.#.###.#.#####v#####.###.###.#.#####.#.#.#############.#.#.#.#.#############.###.#.###########.#######.#####.#.#.#####.#######
###.........#...#.#...#.#...>.>...#...#.#...#.#.....#.#.#.......#...#.#...#.#.#.............###...###.........###...#.......#...#...#.......#
###.#############.#.###.#.###v###.###.#.#.###.#.#####.#.#.#####.#.#.#.#####.#.#.#####################.###########.#.#############.#.#######.#
#...#.....#...###...###.#.#...###.#...#...###...#.....#.#.#...#...#.#.....#.#.#.....###...#.........#.........#...#.......#.......#.......#.#
#.###.###.#.#.#########.#.#.#####.#.#############.#####.#.#.#.#####.#####.#.#.#####.###.#.#.#######.#########.#.#########.#.#############.#.#
#.#...###.#.#.....#...#.#.#.....#.#.#...........#.#...#.#.#.#.....#.......#...#...#.....#.#.......#...#.......#.#.........#.#.....#.....#...#
#.#.#####.#.#####.#.#.#.#.#####.#.#.#.#########.#.#.#.#.#.#.#####.#############.#.#######.#######.###.#.#######.#.#########.#.###.#.###.#####
#...#.....#.#.....#.#.#...###...#...#.......#...#...#...#...#...#.#...#...###...#.........###...#.#...#.###.....#.........#.#.###...###.#...#
#####.#####.#.#####.#.#######.#############.#.###############.#.#.#.#.#.#.###.###############.#.#.#.###.###.#############.#.#.#########.#.#.#
#.....#...#.#...#...#...#.....#...#...###...#.#...#...#...###.#.#...#...#...#.......#...#...#.#.#.#.###.#...#.........#...#.#.#...#.....#.#.#
#.#####.#.#.###.#.#####.#.#####.#.#.#.###.###.#.#.#.#.#.#.###.#.###########.#######.#.#.#.#.#.#.#.#.###v#.###.#######.#.###.#.#.#.#.#####.#.#
#.......#...#...#.#.....#.....#.#...#...#...#.#.#.#.#.#.#.#...#.......#.....#...#...#.#.#.#.#.#.#.#...>.>.#...#.....#...###...#.#.#.......#.#
#############.###.#v#########.#.#######.###.#.#.#.#.#.#.#.#.#########.#.#####.#.#.###.#.#.#.#.#.#.#####v###.###.###.###########.#.#########.#
#...#...#...#.....#.>...#...#.#.#.......#...#...#.#.#.#.#.#...#.....#...#...#.#.#.....#.#.#.#.#...###...###...#.#...#...###.....#...#.....#.#
#.#.#.#.#.#.#######v###.#.#.#.#.#.#######.#######.#.#.#.#.###.#.###.#####.#.#.#.#######.#.#.#.#######.#######.#.#.###.#.###.#######.#.###.#.#
#.#...#...#.........#...#.#.#.#.#...#...#.....#...#.#.#.#...#...#...###...#.#.#.........#.#.#.......#.......#.#.#.#...#...#.......#.#...#...#
#.###################.###.#.#v#.###.#.#.#####.#.###.#.#.###.#####.#####.###.#.###########.#.#######.#######.#.#.#.#.#####.#######.#.###.#####
#.#...#...#...#...###...#.#.>.>.#...#.#.#...#.#.###.#.#.#...#...#.#...#.#...#.......#...#.#.#.......###.....#.#.#...###...#...#...#...#.....#
#.#.#.#.#.#.#.#.#.#####.#.###v###.###.#.#.#.#.#.###.#.#.#.###.#.#v#.#.#.#.#########v#.#.#.#.#.#########.#####.#.#######.###.#.#.#####.#####.#
#...#.#.#...#...#.....#.#.#...###...#.#.#.#.#.#.#...#.#.#.#...#.>.>.#.#.#.....#...>.>.#.#.#.#...#.......#...#...#.......###.#.#.#.....#...#.#
#####.#.#############.#.#.#.#######.#.#.#.#.#.#.#.###.#.#.#.#####v###.#.#####.#.###v###.#.#.###.#.#######.#.#####.#########.#.#.#.#####v#.#.#
#...#.#.#.......#.....#.#.#.......#.#.#.#.#.#.#.#...#...#...###...#...#...#...#.#...###...#...#.#...#...#.#.....#.....#...#.#.#.#...#.>.#...#
#.#.#.#.#.#####.#.#####.#.#######.#.#.#.#.#.#.#.###.###########.###.#####.#.###.#.###########.#.###.#.#.#.#####.#####.#.#.#.#.#.###.#.#v#####
#.#.#...#.....#.#.....#.#...#.....#.#.#.#.#...#.#...###.........###.#...#.#.....#.....#.....#.#.#...#.#...#.....#.....#.#.#.#.#...#...#.....#
#.#.#########.#.#####.#.###.#.#####.#.#.#.#####.#.#####.###########.#.#.#.###########.#.###.#.#.#.###.#####.#####.#####.#.#.#.###.#########.#
#.#...........#.......#...#.#.#...#...#...#...#...#...#...........#.#.#.#.###.........#.#...#...#.....#...#.....#.....#.#.#.#...#.#.........#
#.#######################.#.#.#.#.#########.#.#####.#.###########.#.#.#.#.###.#########.#.#############.#.#####.#####.#.#.#.###.#.#.#########
#.................#######...#.#.#...#...###.#.#.....#.......#...#.#.#.#.#.#...#.......#.#.#.......#.....#.......###...#.#.#.###...#.......###
#################.###########.#.###.#.#.###.#.#.###########.#.#.#.#.#.#.#.#.###.#####.#.#.#.#####.#.###############.###.#.#.#############.###
#.......###...###.....###...#...###...#...#.#.#.....#.....#...#...#...#...#.....#...#.#.#...#...#.#...............#...#.#...###.........#...#
#.#####.###.#.#######.###.#.#############.#.#.#####.#.###.#######################.#.#.#.#####.#.#.###############.###.#.#######.#######.###.#
#.....#.#...#.........#...#.###...........#.#...###...###.........#...###...#.....#...#.#...#.#...###.............###...#.....#.......#.....#
#####.#.#.#############.###.###.###########.###.#################.#.#.###.#.#.#########.#.#.#.#######.###################.###.#######.#######
#...#.#.#.........#####...#...#.....#...###.#...#...###...#.......#.#...#.#.#.....#...#.#.#...###...#...............#.....#...#.......###...#
#.#.#.#.#########.#######.###.#####.#.#.###.#.###.#.###.#.#v#######.###.#.#.#####.#.#.#.#.#######.#.###############.#.#####.###.#########.#.#
#.#.#.#.#...#...#.......#...#.#...#.#.#...#.#...#.#...#.#.>.>.#...#...#.#.#.#...#...#...#.#.....#.#.###...#...#.....#.....#...#...........#.#
#.#.#.#.#.#.#.#.#######.###.#.#.#.#v#.###.#.###.#.###.#.#####.#.#.###.#.#.#.#.#.#########v#.###.#.#.###.#.#.#.#.#########.###.#############.#
#.#.#.#...#...#.........#...#.#.#.>.>.#...#...#.#.#...#...#...#.#.#...#...#.#.#...#...#.>.>.#...#.#.#...#...#...###...#...#...###.......#...#
#.#.#.###################.###.#.#######.#####.#.#.#.#####.#.###.#.#.#######.#.###.#.#.#.#####.###.#.#.#############.#.#.###.#####.#####.#.###
#.#.#.............#.....#...#.#.#######...#...#.#.#...#...#.#...#.#.......#.#.###.#.#.#.#.....#...#.#.........#.....#...#...#...#.....#...###
#.#.#############.#.###.###.#.#.#########.#.###.#.###.#.###.#.###.#######.#.#.###.#.#.#.#.#####.###.#########.#.#########.###.#.#####v#######
#.#...........#...#...#.#...#.#.....#.....#.#...#.###.#.###.#.#...#.......#...###.#.#.#.#.#...#.#...#.........#.........#...#.#.#...>.#.....#
#.###########.#.#####.#.#.###.#####.#.#####.#.###.###.#.###.#.#.###.#############.#.#.#.#.#.#.#.#.###.#################.###.#.#.#.###v#.###.#
#.#.........#...#...#.#.#.#...#.....#.....#.#.....###.#.#...#.#...#.............#.#.#.#.#.#.#...#...#.......#####...#...###.#.#...#...#...#.#
#.#.#######.#####.#.#.#.#.#.###.#########.#.#########.#.#.###.###.#############.#.#.#.#.#.#.#######.#######v#####.#.#.#####.#.#####.#####.#.#
#.#.#.......#...#.#.#.#.#.#...#.....#.....#.........#.#.#.#...#...#.......#...#.#...#.#.#.#.###.....#...#.>.>.#...#.#.#####...#...#.#...#.#.#
#.#.#.#######.#.#.#.#.#.#.###.#####.#.#############.#.#.#.#.###.###.#####.#.#.#.#####.#.#.#.###.#####.#.#.###.#.###.#.#########.#.#.#.#.#.#.#
#...#.#...#...#.#.#.#.#...#...#.....#.....#...#.....#.#.#.#...#...#.....#.#.#...###...#.#.#.#...#...#.#.#...#.#...#.#.....#.....#...#.#...#.#
#####.#.#.#.###.#.#.#.#####.###.#########.#.#.#.#####.#.#.###.###.#####.#.#.#######.###.#.#.#.###.#.#.#.###.#.###.#.#####.#.#########.#####.#
#.....#.#.#.###.#.#.#.....#...#...#.......#.#.#.....#.#.#.#...#...#...#.#.#.......#...#.#.#.#...#.#.#.#.#...#.#...#.#.....#...#.....#.#.....#
#.#####.#.#.###.#.#.#####.###.###.#.#######.#.#####.#.#.#.#.###.###.#.#.#.#######.###.#.#.#.###.#.#.#.#.#.###.#.###.#.#######.#.###.#.#.#####
#.......#...###...#.......###.....#.........#.......#...#...###.....#...#.........###...#...###...#...#...###...###...#######...###...#.....#
###########################################################################################################################################.#

139
2023/day23/main.go Normal file
View File

@ -0,0 +1,139 @@
package main
import (
"fmt"
"os"
h "git.bullercodeworks.com/brian/adventofcode/helpers"
)
func main() {
inp := h.StdinToStringSlice()
if len(os.Args) == 1 || os.Args[1] != "-p2" {
part1(inp)
}
if len(os.Args) == 1 {
fmt.Println()
}
if len(os.Args) == 1 || os.Args[1] != "-p1" {
part2(inp)
}
}
var history map[string]int
func part1(input []string) {
history = make(map[string]int)
m := h.StringSliceToCoordByteMap(input)
start, _ := m.FindFirst('.')
start.Y++
end, _ := m.FindLast('.')
fmt.Println("# Part 1")
fmt.Println(len(findPath(&m, start, end, []h.Coordinate{})))
}
func part2(input []string) {
history = make(map[string]int)
m := h.StringSliceToCoordByteMap(input)
start, _ := m.FindFirst('.')
start.Y++
end, _ := m.FindLast('.')
m.ReplaceAll('^', '.')
m.ReplaceAll('>', '.')
m.ReplaceAll('v', '.')
m.ReplaceAll('<', '.')
fmt.Println("# Part 2")
fmt.Println(len(findPath(&m, start, end, []h.Coordinate{})))
}
func findPath(m *h.CoordByteMap, pos h.Coordinate, end h.Coordinate, path []h.Coordinate) []h.Coordinate {
ret := []h.Coordinate{pos}
if pos.Equals(end) {
//printPath(m, pos, path)
//time.Sleep(time.Second / 20)
return ret
}
path = append(path, pos)
switch m.Get(pos) {
case '^':
if inPath(pos.North(), path) {
return ret
} else {
return append(ret, findPath(m, pos.North(), end, path)...)
}
case '>':
if inPath(pos.East(), path) {
return ret
} else {
return append(ret, findPath(m, pos.East(), end, path)...)
}
case 'v':
if inPath(pos.South(), path) {
return ret
} else {
return append(ret, findPath(m, pos.South(), end, path)...)
}
case '<':
if inPath(pos.West(), path) {
return ret
} else {
return append(ret, findPath(m, pos.West(), end, path)...)
}
}
var longestPath []h.Coordinate
longest := h.MIN_INT
for _, chk := range []h.Coordinate{pos.North(), pos.East(), pos.South(), pos.West()} {
if m.Get(chk) == '#' || inPath(chk, path) || !m.ContainsCoord(chk) {
continue
}
var run bool
var v int
if v, run = history[chk.String()]; run {
run = v < len(path)+1
}
if run {
history[chk.String()] = len(path) + 1
chkPath := append(ret, findPath(m, chk, end, path)...)
if inPath(end, chkPath) && len(chkPath) > longest {
longest = len(chkPath)
longestPath = chkPath
}
}
}
return longestPath
}
func inPath(pos h.Coordinate, path []h.Coordinate) bool {
for _, chk := range path {
if chk.Equals(pos) {
return true
}
}
return false
}
func printPath(m *h.CoordByteMap, pos h.Coordinate, path []h.Coordinate) {
limit := (m.BRY - m.TLY) > 30
fmt.Print(h.CLEAR_SCREEN)
for y := m.TLY; y <= m.BRY; y++ {
if limit && h.Abs(pos.Y-y) > 15 {
continue
}
for x := m.TLX; x <= m.BRX; x++ {
chk := h.Coordinate{X: x, Y: y}
if chk.Equals(pos) {
fmt.Print("@")
} else {
if inPath(chk, path) {
fmt.Print("O")
} else {
fmt.Print(string(m.Get(chk)))
}
}
}
fmt.Println()
}
}

23
2023/day23/testinput Normal file
View File

@ -0,0 +1,23 @@
#.#####################
#.......#########...###
#######.#########.#.###
###.....#.>.>.###.#.###
###v#####.#v#.###.#.###
###.>...#.#.#.....#...#
###v###.#.#.#########.#
###...#.#.#.......#...#
#####.#.#.#######.#.###
#.....#.#.#.......#...#
#.#####.#.#.#########v#
#.#...#...#...###...>.#
#.#.#v#######v###.###v#
#...#.>.#...>.>.#.###.#
#####v#.#.###v#.#.###.#
#.....#...#...#.#.#...#
#.#########.###.#.#.###
#...###...#...#...#.###
###.###.#.###v#####v###
#...#...#.#.>.>.#.>.###
#.###.###.#.###.#.#v###
#.....###...###...#...#
#####################.#

View File

@ -86,6 +86,16 @@ func (m *CoordByteMap) Height() int {
func (m *CoordByteMap) Width() int {
return m.BRX - m.TLX
}
func (m *CoordByteMap) ReplaceAll(o, n byte) {
for y := m.TLY; y <= m.BRY; y++ {
for x := m.TLX; x <= m.BRX; x++ {
c := Coordinate{X: x, Y: y}
if m.Get(c) == o {
m.Put(c, n)
}
}
}
}
func (m *CoordByteMap) ToByteSlices() [][]byte {
var ret [][]byte
@ -167,6 +177,20 @@ func (m *CoordByteMap) FindFirst(b byte) (Coordinate, error) {
return Coordinate{}, errors.New("Not Found")
}
// FindLast searches right to left, bottom to top for the last
// instance of b
func (m *CoordByteMap) FindLast(b byte) (Coordinate, error) {
for y := m.BRY; y >= m.TLY; y-- {
for x := m.BRX; x >= m.TLX; x-- {
c := Coordinate{X: x, Y: y}
if m.Get(c) == b {
return c, nil
}
}
}
return Coordinate{}, errors.New("Not Found")
}
func (m *CoordByteMap) FindAll(b ...byte) []Coordinate {
var ret []Coordinate
for y := m.TLY; y <= m.BRY; y++ {