This commit is contained in:
Christian
2023-12-24 22:07:47 +01:00
parent be15ba2bac
commit ebaba04774
2 changed files with 460 additions and 0 deletions

141
data/23.in 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#.#.###
###...#.........#...............###...#...#####...#.....#.....#...#...###...###...#...###.........#...#...#.....#...#...#...#...#...#...#...#
###########################################################################################################################################.#

319
src/bin/day23.rs Normal file
View File

@@ -0,0 +1,319 @@
use hashbrown::HashMap;
use std::ops::{Index, IndexMut};
#[derive(PartialEq, Eq, PartialOrd, Ord, Copy, Clone, Hash, Debug)]
struct Pos {
x: usize,
y: usize,
}
impl Pos {
fn north(&self) -> Self {
Pos {
x: self.x - 1,
y: self.y,
}
}
fn south(&self) -> Self {
Pos {
x: self.x + 1,
y: self.y,
}
}
fn west(&self) -> Self {
Pos {
x: self.x,
y: self.y - 1,
}
}
fn east(&self) -> Self {
Pos {
x: self.x,
y: self.y + 1,
}
}
}
struct Grid<T> {
buffer: Vec<T>,
height: usize,
width: usize,
}
impl<T: Clone> Grid<T> {
fn new(height: usize, width: usize, default: T) -> Self {
Self {
buffer: vec![default; height * width],
height,
width,
}
}
fn from_buffer(buffer: Vec<T>, width: usize) -> Self {
let height = buffer.len() / width;
Self {
buffer,
height,
width,
}
}
fn adj4<'a>(&'a self, pos: &Pos) -> impl Iterator<Item = Pos> + 'a {
[
(pos.x.wrapping_sub(1), pos.y),
(pos.x + 1, pos.y),
(pos.x, pos.y.wrapping_sub(1)),
(pos.x, pos.y + 1),
]
.into_iter()
.filter(|(x, y)| (x < &self.height) & (y < &self.width))
.map(|(x, y)| Pos { x, y })
}
}
impl<T> Index<Pos> for Grid<T> {
type Output = T;
fn index(&self, index: Pos) -> &Self::Output {
&self.buffer[index.x * &self.width + index.y]
}
}
impl<T> IndexMut<Pos> for Grid<T> {
fn index_mut(&mut self, index: Pos) -> &mut Self::Output {
&mut self.buffer[index.x * &self.width + index.y]
}
}
fn search(grid: &Grid<u8>, seen: &mut Grid<bool>, pos: Pos, steps: usize) -> usize {
let destination = Pos {
x: grid.height - 1,
y: grid.width - 2,
};
if pos == destination {
return steps;
}
if seen[pos] {
return 0;
}
let steps = steps + 1;
seen[pos] = true;
let result = match grid[pos] {
b'v' => search(grid, seen, pos.south(), steps),
b'^' => search(grid, seen, pos.north(), steps),
b'>' => search(grid, seen, pos.east(), steps),
b'<' => search(grid, seen, pos.west(), steps),
b'.' => grid
.adj4(&pos)
.map(|pos| search(grid, seen, pos, steps))
.fold(0, std::cmp::max),
_ => 0,
};
seen[pos] = false;
return result;
}
fn search_p2(grid: &Grid<u8>, seen: &mut Grid<bool>, pos: Pos, steps: usize) -> usize {
let destination = Pos {
x: grid.height - 1,
y: grid.width - 2,
};
if pos == destination {
return steps;
}
if seen[pos] {
return 0;
}
seen[pos] = true;
let result = match grid[pos] {
b'#' => 0,
_ => grid
.adj4(&pos)
.map(|pos| search(grid, seen, pos, steps + 1))
.fold(0, std::cmp::max),
};
seen[pos] = false;
return result;
}
type Node = u8;
type Graph = Vec<Vec<(Node, u32)>>;
fn find_longest_path(
graph: &Graph,
mut seen: u64,
source: Node,
dest: Node,
distance: usize,
) -> usize {
if source == dest {
return distance;
}
seen |= 1 << source;
let mut result = 0;
for (next, dist) in graph[source as usize].iter().copied() {
if seen & (1 << next) == 0 {
result = result.max(find_longest_path(
graph,
seen,
next,
dest,
distance + dist as usize,
));
}
}
return result;
}
fn find_longest_path_no_rec(
graph: &Graph,
source: Node,
dest: Node
) -> usize {
let mut stack = Vec::from([(source, 0u64, 0)]);
stack.reserve(63);
let mut result = 0;
while let Some((source, mut seen, distance)) = stack.pop() {
if source == dest {
result = result.max(distance);
} else {
seen |= 1 << source;
let v = unsafe { graph.get_unchecked(source as usize) };
for (next, dist) in v.iter().copied() {
if seen & (1 << next) == 0 {
stack.push((next, seen, distance + dist as usize));
}
}
}
}
result
}
fn construct_graph(grid: &Grid<u8>) -> (Graph, Node, Node) {
let mut seen = Grid::new(grid.height, grid.width, false);
let mut todo = Vec::new();
let mut next = Vec::new();
let mut graph = HashMap::new();
let destination = Pos {
x: grid.height - 1,
y: grid.width - 2,
};
let initial = Pos { x: 0, y: 1 };
todo.push((initial, initial, initial, 0));
while !todo.is_empty() {
for (pos, prev, mut last_node, mut dist) in todo.iter().copied() {
let is_node = 2 < grid.adj4(&pos).filter(|p| grid[*p] != b'#').count();
if is_node || pos == destination {
graph
.entry(last_node)
.or_insert(Vec::new())
.push((pos, dist));
graph
.entry(pos)
.or_insert(Vec::new())
.push((last_node, dist));
last_node = pos;
dist = 0;
if !seen[pos] {
seen[pos] = true;
for neigh in grid.adj4(&pos) {
if neigh != prev && grid[neigh] != b'#' {
next.push((neigh, pos, last_node, dist + 1));
}
}
}
} else {
for neigh in grid.adj4(&pos) {
if neigh != prev && grid[neigh] != b'#' {
next.push((neigh, pos, last_node, dist + 1));
}
}
}
}
todo.clear();
todo.append(&mut next);
}
for v in graph.values_mut() {
v.sort();
let mut nv = Vec::new();
let mut last = v[0];
for &v in v.iter().skip(1) {
if v.0 != last.0 {
nv.push(last);
}
last = v;
}
nv.push(last);
v.clear();
v.append(&mut nv);
}
let node_idx: HashMap<Pos, u8> = graph.keys().copied().zip(0..).collect();
let start = node_idx[&initial];
let destination = node_idx[&destination];
let mut graph_vec = vec![Vec::new(); node_idx.len()];
graph
.iter()
.map(|(k, v)| {
(
node_idx[k],
v.iter()
.map(|(n, dist)| (node_idx[n], *dist))
.collect::<Vec<(Node, u32)>>(),
)
})
.for_each(|(node, adj)| {
graph_vec[node as usize] = adj;
});
// let m = graph_vec.iter().map(|v| v.len()).reduce(std::cmp::max).unwrap();
// let mut gridify = vec![(63, 0); 63 * graph_vec.len()];
// for (id, adjs) in graph_vec.iter().enumerate() {
// for (aid, adj) in adjs.iter().enumerate() {
// gridify[id * m + aid] = *adj;
// }
// }
// println!("{}", graph_vec.len());
(graph_vec, start, destination)
}
fn main() {
let filename = std::env::args().nth(1).unwrap();
let input = std::fs::read_to_string(filename).unwrap();
let width = input.lines().next().unwrap().len();
let buffer: Vec<_> = input.lines().flat_map(|line| line.bytes()).collect();
let height = buffer.len() / width;
let grid = Grid::from_buffer(buffer, width);
let mut seen = Grid::new(height, width, false);
let longest_path = search(&grid, &mut seen, Pos { x: 0, y: 1 }, 0);
println!("1) {}", longest_path);
let (graph, start, destination) = construct_graph(&grid);
//let part2 = find_longest_path(&graph, 0, start, destination, 0);
let part2 = find_longest_path_no_rec(&graph, start, destination);
println!("{}", part2);
}