From 5204bf0d60d0ffbb70f6469df89b74662edadf3e Mon Sep 17 00:00:00 2001 From: Dory Date: Sun, 24 Dec 2023 15:40:59 -0800 Subject: [PATCH] d23p1 --- 23/input.txt | 141 +++++++++++++++++++++++++++++++++++++++++++++++++++ 23/part1.pl | 51 +++++++++++++++++++ 23/test.txt | 23 +++++++++ 3 files changed, 215 insertions(+) create mode 100644 23/input.txt create mode 100644 23/part1.pl create mode 100644 23/test.txt diff --git a/23/input.txt b/23/input.txt new file mode 100644 index 0000000..438de80 --- /dev/null +++ b/23/input.txt @@ -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#.###.#####.###.#.#.###.#.#.#######.# +#.#.#.......#...###...#...#.#.#...#...#.#.#.#.#.#.#.#.###.#.#.#.#.#.#...#.#.#...#.#...#.......#.#...#.>.>.###...#...###.#.#...#.#.#.#.......# +#.#.#######.#.#.#####.#####.#.#.#####.#.#.#.#.#.#.#.#.###.#.#.#.#.#.###.#.#.#.###.#.###.#######.###.#.#########.#.#####.#.###.#.#.#.#.####### +#.#.........#.#.#...#.....#...#...#...#...#.#.#...#.#.#...#.#.#.#.#.#...#.#.#...#.#.###.#...#...#...#...#.......#.....#.#.#...#.#.#.#.#...### +#.###########.#.#.#.#####.#######.#.#######.#.#####.#.#.###.#.#.#.#.#.###.#.###.#.#.###.#.#.#.###.#####.#.###########.#.#.#.###.#.#.#.#.#.### +#.#...#...#...#.#.#.#...#.......#.#.....#...#.....#.#.#...#.#.#.#.#.#...#.#.#...#.#...#.#.#.#.###...#...#.......#.....#...#...#.#...#...#...# +#.#.#.#.#.#.###.#.#.#.#.#######.#.#####.#.#######.#.#.###.#.#.#.#.#.###.#.#.#.###.###.#.#.#.#.#####.#.#########.#.###########.#.###########.# +#.#.#.#.#.#...#.#.#.#.#.#.......#.#.....#.#...#...#.#...#.#.#.#.#.#.###.#.#.#...#...#.#.#.#.#...#...#.......###.#.......#...#...###...#...#.# +#.#.#.#.#.###.#.#.#.#.#.#.#######.#.#####.#.#.#.###.###.#.#.#.#.#.#.###.#.#.###.###.#.#.#.#.###.#.#########.###.#######.#.#.#######.#.#.#.#.# +#.#.#.#.#.#...#.#.#.#.#.#.......#.#.....#.#.#.#.#...#...#.#.#.#.#.#.#...#.#...#...#.#.#.#.#...#.#...#.....#...#...#.....#.#.........#...#...# +#.#.#.#.#.#.###.#.#.#.#.#######.#.#####.#.#.#.#.#.###.###.#.#.#.#.#.#.###.###.###.#.#.#.#.###.#.###.#.###.###.###.#.#####.################### +#...#...#...###...#...#.........#.......#...#...#.....###...#...#...#.....###.....#...#...###...###...###.....###...#####...................# +###########################################################################################################################################.# diff --git a/23/part1.pl b/23/part1.pl new file mode 100644 index 0000000..6a3f64e --- /dev/null +++ b/23/part1.pl @@ -0,0 +1,51 @@ +:- use_module(library(pio)). +:- use_module(library(dcg/basics)). +:- initialization(main, main). + +main([FileName|_]) :- + input(FileName, Map), + nth1(1, Map, Row1), nth1(StartY, Row1, '.'), + findall(N, route(Map, visited{}, 1-StartY, N), Ns), + max_list(Ns, Answer), + format('~w <- ~w', [Answer, Ns]), nl. + +route(Map, _, X-_, 0) :- length(Map, Height), X =:= Height. +route(Map, Visiteds, X-Y, N) :- + Key is X*1000 + Y, NextVisiteds = Visiteds.put(Key, true), + neighbor(Map, X-Y, X1-Y1, Dist), + NeighborKey is X1*1000 + Y1, \+ _= Visiteds.get(NeighborKey), + route(Map, NextVisiteds, X1-Y1, N1), + N is N1 + Dist. + +neighbor(Map, X-Y, NextX-NextY, Dist) :- + ( X1 is X + 1, Y1 = Y; + X1 is X - 1, Y1 = Y; + X1 = X, Y1 is Y + 1; + X1 = X, Y1 is Y - 1 + ), + nth1(X1, Map, Row1), nth1(Y1, Row1, Cell1), + ( Cell1 = '.' -> NextX = X1, NextY = Y1, Dist = 1 + ; Cell1 = '>' -> NextX = X1, NextY is Y1 + 1, Dist = 2 + ; Cell1 = 'v' -> NextX is X1 + 1, NextY = Y1, Dist = 2 + ), + ( NextX =\= X; NextY =\= Y ). + +% input parsing stuff below. Brick indexing is for debugging. +input(FileName, Map) :- phrase_from_file(lines(Map), FileName). + +lines([]) --> eos, !. +lines([Line|Lines]) --> line(Line), lines(Lines). + +line([]) --> ("\n"; eos), !. +line([C|Chars]) --> [Ascii], line(Chars), {atom_codes(C, [Ascii])}. + +% debug +print(Map) :- + findall( + X, + ( nth1(X, Map, Line), + format('~3d', [X]), write(" "), + atomic_list_concat(Line, Str), write(Str), nl + ), + _), + nl. diff --git a/23/test.txt b/23/test.txt new file mode 100644 index 0000000..ea945a4 --- /dev/null +++ b/23/test.txt @@ -0,0 +1,23 @@ +#.##################### +#.......#########...### +#######.#########.#.### +###.....#.>.>.###.#.### +###v#####.#v#.###.#.### +###.>...#.#.#.....#...# +###v###.#.#.#########.# +###...#.#.#.......#...# +#####.#.#.#######.#.### +#.....#.#.#.......#...# +#.#####.#.#.#########v# +#.#...#...#...###...>.# +#.#.#v#######v###.###v# +#...#.>.#...>.>.#.###.# +#####v#.#.###v#.#.###.# +#.....#...#...#.#.#...# +#.#########.###.#.#.### +#...###...#...#...#.### +###.###.#.###v#####v### +#...#...#.#.>.>.#.>.### +#.###.###.#.###.#.#v### +#.....###...###...#...# +#####################.#