summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorToby Vincent <tobyv@tobyvin.dev>2023-12-13 19:14:09 -0600
committerToby Vincent <tobyv@tobyvin.dev>2023-12-14 17:11:00 -0600
commit72a0110013c22953cc7f0a257dc8d277019c9af3 (patch)
tree9cc43ca282167d7caf99f3872b7c15d29aabbf5e
parent46e2184709040f948f8664a45a43f4959aed9183 (diff)
feat: impl day 13
-rw-r--r--input/day_13.txt1353
-rw-r--r--src/day_13.rs219
-rw-r--r--src/lib.rs1
-rw-r--r--src/main.rs3
4 files changed, 1575 insertions, 1 deletions
diff --git a/input/day_13.txt b/input/day_13.txt
new file mode 100644
index 0000000..beb6032
--- /dev/null
+++ b/input/day_13.txt
@@ -0,0 +1,1353 @@
+#..##..
+#.#.##.
+#.####.
+.####..
+#.###.#
+...####
+#...#..
+..#.#..
+#...##.
+.#####.
+.#....#
+.#####.
+.####..
+###.###
+###.###
+.####..
+.#####.
+
+#.##..#..######..
+....##.##..##..##
+###...##..#..#..#
+###...##..#..#..#
+....##.##..##..##
+#.##..#..######..
+.#..###.###..###.
+####...###...####
+######..########.
+.#..#....#.##.#..
+##...###.#....#.#
+
+#...##...#..#.#..
+#...##...#..#.#..
+.#.#...#.#....#..
+#.#..#.##..##.#.#
+#..###.#..#..#...
+###.#####.##.#.#.
+##############...
+#.....#######..#.
+..##..##.####..##
+#.####..##.#..#.#
+#.####..##.#..#.#
+..##..##.####..##
+#.....#######..#.
+##############..#
+###.#####.##.#.#.
+#..###.#..#..#...
+#.#..#.##..##.#.#
+
+.#.....##.....#
+.#.....##.....#
+.##.##...#.##..
+##.##.#.#.##..#
+######..#.#..##
+..#.#..#.#..#.#
+.....#..###.#.#
+###..#.##..#..#
+#..#.##.#..#.#.
+#..#.##.#..#.#.
+###..#.##..#..#
+.....#..###.#.#
+..#.#.##.#..#.#
+######..#.#..##
+##.##.#.#.##..#
+.##.##...#.##..
+.#.....##.....#
+
+###..##########
+#.####.#....#.#
+.#....#.####.#.
+#.####.##..##.#
+#.#..#.######.#
+..###..........
+##....##....##.
+
+####...#.##.###
+..##...##...#.#
+.#...##.#.#####
+###...#...###..
+..#....#...#...
+.###.#####.#...
+##...#####..#..
+.####...##...##
+#.#.#.#..###...
+..##.#.####..##
+#..##.##.####..
+##..#.#..#..#..
+..###.#.#.#..##
+..###.#.#.#..##
+##..#.#..#..#..
+
+###.#..#.#####.##
+..#.#..#.#.......
+....####.#...#.##
+#...#..#...##.###
+#...####...#.###.
+#.#.#..#.#.###.#.
+#..#....#..#.....
+.##########..###.
+##.#....#.###..#.
+#...####...###.##
+#...####...###.##
+##.#....#.###..#.
+.##########..###.
+#..#....#..#.....
+#.#.#..#.#.###.#.
+#...####...#.###.
+#...#..#...##.###
+
+#####..#.
+#..#.#.#.
+#####..#.
+.##.##..#
+....#.###
+....#####
+.##.##..#
+
+#####..
+..#.##.
+..#.##.
+#####..
+##.....
+###.##.
+#..#.##
+######.
+..##.##
+..#.#..
+..#####
+
+#.###..###.##.#
+#.#..##..#.##.#
+#.##.##.##.##.#
+##........####.
+.#.#.##.#.#..#.
+#..........##..
+###.####.######
+##.#.##.#.####.
+..########....#
+.#..####..####.
+..##.##.##....#
+
+.......##..##
+..##...#.#...
+.#..#...#.###
+.####...#..##
+##..##.####.#
+#.##.#.#.....
+.......#.##..
+..##..#.#.###
+......#..#..#
+.......#.##.#
+......#..#.##
+#...##..#..##
+.####.#.#..##
+.####.#.##...
+.####.#.##...
+
+...#........#..
+##.#..#..#..#.#
+##.##.####.##.#
+##..##.##.##..#
+...#..#..#..#..
+..#..######..#.
+...#.#.##.#.#..
+..##...##...##.
+...#...##...#..
+##..###..###..#
+...#..####..#..
+...###....###..
+.......##......
+####..####..###
+#####......###.
+..#..######..#.
+..#..#....#..#.
+
+.#.#..#.##.##.##.
+#.#....#.######.#
+####.#..#......#.
+.#.#.#..#.####.#.
+..#####.##....##.
+###..#...........
+...##.#.#..##..#.
+..###.##...##...#
+..######...##...#
+
+....###.##.###.
+#.#####.#...#.#
+#..#.#...##.###
+..#####..##.##.
+..#####..##.##.
+#..#.#..###.###
+#.#####.#...#.#
+....###.##.###.
+...###.#.###...
+...##...#..#...
+.####.#....###.
+.####.#....###.
+...##...#..#...
+
+####.####
+##.#.###.
+####..#.#
+##.##...#
+#####..#.
+####.####
+###....#.
+####.#..#
+###.#.###
+..#..#.#.
+##.#.....
+....#..#.
+..##.####
+..##...#.
+..##...#.
+..##.####
+....#....
+
+..#....#..##.##
+..##..##..#.#.#
+..##..##....#..
+..##..##....#..
+..##..##..#.#.#
+..##..##..##.##
+##..##..##.#..#
+....##.....#..#
+.#.####.#...#.#
+
+...##.#.#..##
+.#.#..#.#..##
+.##.##...#..#
+.##.##...#..#
+.#.#..#.#..##
+...##.#.#..##
+.#.#.##....#.
+########....#
+##..#.#...#.#
+......##.....
+#..#.....###.
+#.#.#####.##.
+#.#.#####.##.
+#..#.....###.
+......##.....
+##..#.#.#.#.#
+########....#
+
+##.##.####.
+#..##..##..
+.##..##..##
+###..######
+.#.##.#..#.
+.##..##..##
+###..######
+#.####.##.#
+#..##.####.
+
+##.#.#####.####
+##..#..#.##....
+##.#..#.#.#.#..
+##..##.#....##.
+..##.#...##.#..
+..##..###.#....
+#####.##...#.##
+##.....#.##..##
+##..########...
+###....#..#.###
+...##.######.##
+###...#########
+##.#.##.##.##..
+...##.####.#.##
+##..#..###.#.##
+###.##.##.#.###
+...####..###...
+
+.####.#..#.
+.####.#..#.
+......##.##
+.####.#.###
+.#..#.##.##
+.###..##.#.
+##..##...#.
+......#####
+######.##.#
+#.##.##.#.#
+......#.#..
+
+##..##..###.#
+.##........##
+...########..
+.#.#.####.#.#
+#.####..####.
+#.##......##.
+.##.#.##.#.##
+..#..#..#..#.
+#.###....###.
+....######...
+.#..........#
+#.#.######.#.
+#..###..###..
+#.#........#.
+#.#........#.
+#..###..###..
+#.#.######.#.
+
+..##...#....####.
+##.....###..#..#.
+####.#.###.######
+####...#.#.######
+..####.#.###....#
+..##.#..##...##..
+###..######......
+...####.###....#.
+##...####.#.####.
+####..####.##..##
+##.#..#.#.#.####.
+..........##.##.#
+..#...####.#.##.#
+
+..###..#.#.....
+.##.#.##.......
+...#.##..#.....
+#.##....#..####
+...#..####.#..#
+.####.###.#....
+##..#####......
+##..#..#.......
+..####..#......
+
+.......####
+.......####
+##..#..##.#
+....#.##.##
+..###.#...#
+.#.##..##..
+##.#.##...#
+.#.#.##...#
+.#.##..##..
+..###.#...#
+....#.##.##
+
+####.....#..#...#
+####.....#..#...#
+####.##.#.###.###
+.###.###.....##.#
+....###.#.#.#.#..
+...#..#..#.##..#.
+##...#########..#
+###.#.#.##...####
+#...#..#.##...#..
+#...#..#.##...#..
+###.#.#.##...####
+###..#########..#
+...#..#..#.##..#.
+....###.#.#.#.#..
+.###.###.....##.#
+
+.##.#....#.##.#
+..##....#.###.#
+..##....#.###..
+#.##.##.#......
+.####..#..##.##
+..##..##..####.
+......#.##.###.
+#....###..###.#
+......####..#.#
+.####.#.#####.#
+#.##.#......#.#
+.####...##.#.#.
+.####...##.#.#.
+#.##.#......#.#
+.####.#.#####.#
+
+##....#.#.#..#.
+##..####..#..#.
+....#.##..#..#.
+###.#.#........
+#.###...#######
+..#.#.##.......
+....#..........
+##.##..####..##
+..#...###..##..
+........#.#####
+........#.#####
+
+##.#.##
+##.#.##
+..#.#..
+.######
+#...#.#
+#.#####
+#.###.#
+
+...#.####...##...
+...#..###...##...
+.##.##.##..#...##
+..##.#.##....####
+..##.#.##....####
+.##.##.##..#...##
+...#..###...##...
+...#.####...##...
+#.#.##...##....#.
+#####.###..#####.
+...#..#....#.#..#
+
+###.#.###.#
+..#.##.#...
+########.##
+##.##.#..#.
+..#...##.#.
+.....####.#
+.#.#######.
+##...#.####
+...#..#..##
+####.#.####
+##..######.
+.........#.
+.........#.
+##..######.
+####.#.####
+
+#.#.#.##.
+...##...#
+...##...#
+#.#.#.#..
+#..######
+.#.##..##
+.###.#.##
+#...####.
+#..##....
+....#.#.#
+####.#.#.
+###...#..
+.#.##...#
+##.####..
+##.####..
+.#.##...#
+###...#..
+
+##....#####.#
+.#.##.#.#..#.
+########..#..
+##....####..#
+##....####.#.
+#.#..#.#####.
+##.##.##...##
+##.##.##...##
+#.#..#.##.##.
+##....####.#.
+##....####..#
+
+#.##.#.#.###...
+#.##.###.###...
+..##........##.
+.####.##...#.##
+......#.....##.
+..##..#.#.#..#.
+.####.###.#####
+########.#.....
+#.##.####.###.#
+#....##.#..##.#
+.####.###.#..##
+
+.#.#....#.#..
+##.#....#.###
+.....##......
+.#.######....
+.###....###..
+..#.#..#.#...
+#..##..##..##
+#..######..##
+###..##..####
+...#....#....
+.##..##..##..
+
+...#.#.......
+###.####...##
+..##...##.#.#
+###.##..#.#.#
+##....##.####
+##....##.####
+###..#..#.#.#
+
+..##.####
+.#..#....
+....#....
+..#.#####
+#####....
+.##.#####
+##....##.
+#....####
+.....####
+#..#.####
+..#.#....
+#.##.####
+###..####
+
+######.#.##
+#.###..#..#
+..#..##...#
+#...##..##.
+.....##.#.#
+....#...#..
+....#...#..
+.....##.#.#
+#...##..##.
+..#..##...#
+#####..#..#
+######.#.##
+######.#.##
+
+...##....#..##..#
+..#..#..##.#..#.#
+.######.###....##
+#.####.###.####.#
+...##...#.##..##.
+..####....######.
+#.#..#.#..##..##.
+.######.##..##..#
+#......#.#.#..#.#
+##....####......#
+.##.###.##......#
+##.##.###..#..#..
+########....##...
+#..##..###.####.#
+.##..##..#......#
+#.####.#.#..##..#
+#.####.#.#.####.#
+
+##.###..###.#
+..###.##.###.
+.#..........#
+#............
+#...######...
+..##.####.##.
+.##.######.##
+.##.######.##
+###.#.##...##
+..##.#..#.##.
+..##.#..#.##.
+
+..#.###.###
+.......#.#.
+.......#.#.
+..#.###..##
+#.#####.##.
+##..#####..
+#....#.##.#
+#.#.####..#
+.##.###.###
+#..###..#.#
+...#...##..
+...#...##..
+#..###..#.#
+
+#####........#.#.
+#####........#.#.
+.#.#.#.###..##..#
+.##...#.#..##.###
+#..#....#.....#.#
+..#..##..#.#.#..#
+...#....#.##..#..
+#..#####....##.##
+.###...##.#.#####
+.###...##.#.#####
+#..#####....##.##
+...#....#.##..#..
+..#..##..#.#.#..#
+#..#....#.....#.#
+.##...#.#..##.###
+.#.#.#..##..##..#
+#####........#.#.
+
+.#.##.#.#......
+##.##.##...##..
+.######..#....#
+#..##..##.#..#.
+.##..##........
+##.##.##..#..#.
+#......##.####.
+#.####.##.#..#.
+.##..##..#.##.#
+..####....####.
+#.####.###....#
+#..##..##.####.
+.#.##.#.#...#..
+##....##.......
+...##.....#..#.
+#..##..#.......
+#......########
+
+###.##....##...
+#..####.##..#.#
+#..####.##..#.#
+###.##....##...
+.##.#########.#
+.#.##.#.##.#...
+.....##..#.#.##
+.###....#....##
+...###.#...#...
+..#.##..##...##
+..#.##..#....##
+...###.#...#...
+.###....#....##
+
+##.#..#....#.
+#######.##.##
+.##.#..#..#..
+.#......##...
+...##.#######
+...##.#######
+.#......##...
+.##.#..#..#..
+#######.##.##
+
+#.#######
+.....#..#
+##..#####
+..#..####
+####.####
+##.##....
+###......
+.########
+#####....
+
+#..........
+#.....#....
+#.##.#...#.
+#####..#.#.
+..##..##..#
+###..##.#..
+..#..#...#.
+.#.#.#.##.#
+.#.#.#.##.#
+..#..#...#.
+###..##.#..
+..##..##..#
+#####..#.#.
+
+...#.###...####.#
+...#.###...###..#
+#..#..##.##...#.#
+#.#..##.##.....#.
+##.###.#.####.###
+#..#..##..#.##..#
+#..#..##..#.##..#
+
+..#.##...####
+#...#.#..#..#
+.#####.#.#..#
+.#####.#.#..#
+#...#.#..#..#
+..#.##...####
+#.....#.##..#
+##.##.####...
+#....#####..#
+.....#.......
+..#..########
+##.##########
+#.####.#..##.
+
+.####..##..##
+.####..##..##
+.....#...##..
+#.##..##.##.#
+##........#..
+..####..####.
+#...##..#..#.
+##..#........
+...##.#..##..
+
+#....####....##
+###....#...####
+.#.##.##.##.#..
+#...#.##.#...##
+.#.##.##.##.#..
+.#...#..#...#..
+...###..###....
+
+...##....###..#
+########..###..
+........###...#
+........###...#
+########..###..
+...##....###..#
+.#.##.#...#####
+..#.....##.###.
+.#.##.#.#.##..#
+
+..#.###.#
+..##....#
+.###.#...
+#....#.##
+#....#.##
+.###.#...
+..##....#
+..#.###.#
+..#.##..#
+
+.##.###.#####
+.##.#..#.....
+##.###.....##
+#####..#...##
+#####.....###
+.##..##.#.#..
+......##.....
+
+#.#.#...#####
+#.#.....#####
+.#.#.###....#
+###..#....##.
+#.#....##..#.
+..####.#.####
+#.#.#.####...
+..##.......#.
+.##.######.#.
+.##.#.#..####
+.##.#.#..####
+
+##...####
+##...####
+...#..##.
+..##..#.#
+#.###.#..
+##.###.##
+...##.#.#
+##.##.###
+..#.....#
+..#.....#
+##.##.#.#
+...##.#.#
+##.###.##
+#.###.#..
+..##..#.#
+...#..##.
+##...####
+
+##..##....##.#.
+..##..##..#...#
+######.##.#....
+.####...#.#..#.
+#######.#..#..#
+#....##...#.##.
+#....##...#.##.
+#######.#..#..#
+.####.....#..#.
+######.##.#....
+..##..##..#...#
+##..##....##.#.
+.#..#..#....##.
+#.##.###...###.
+..##..#.#######
+#######....#...
+##..####.#..##.
+
+...........#...#.
+.#.#..#.#.....###
+..#.##.#.......#.
+##########.#..#.#
+##.####.##....#.#
+##.####.##....#.#
+##########.#..#.#
+..#.##.#.......#.
+.#.#..#.#.....###
+...........#...#.
+...#..#...##..##.
+#.#....#.###.##..
+##.##.#.##..##..#
+
+....#.###......
+......##.##..#.
+.##..#...#.#.#.
+.##...##...#.##
+.##...##...#.##
+.##..#...#.#.#.
+......##.##..#.
+....#.###......
+.....#..#.##..#
+####...####..##
+...###.#.#..###
+#####.#.##.####
+#..##.#..#..###
+....##...#....#
+.....###.#.#.#.
+#..##.##....#..
+.##....##..#..#
+
+#..........###..#
+#.##....##.###..#
+.##########......
+####.#..####..##.
+..#..##..#..#....
+..##....##...#..#
+#...#..#...##....
+##.##..##.####..#
+.##########.#....
+.#..#..#..#.#####
+#...####...######
+.#..#..#..#......
+..#......#..#####
+#..#....#..##....
+#.#..##..#.#.####
+
+...##.#
+...##.#
+...#...
+#.####.
+#..#.#.
+..###..
+##..#..
+##..#..
+..###..
+##.#.#.
+#.####.
+...#...
+...##.#
+
+#.##.#....#..
+..##..####.##
+#....#.#..#..
+##..####...##
+.####....#...
+##..##.#.#...
+########.####
+#.##.##.#.###
+..##.....##..
+.........##..
+.....#.##..##
+
+###.##.
+###.##.
+..##...
+#..#.#.
+.#.#.##
+#..###.
+..##.##
+#.#.###
+.#.##..
+..#.###
+..#####
+#....##
+#..#.##
+
+..##########.##
+#...##..#.#####
+#####.####..##.
+.#.###..#......
+####..###.#....
+##...#.#.######
+#.######.##.##.
+#.#.#..#...#..#
+.####....##.##.
+.#.#.#.###.####
+.....###.##.##.
+.....###.##.##.
+.#.#.#.###.####
+.####....##.##.
+#.#.#..#...#..#
+
+#..####.##.####
+###....#..#....
+###.##.####.##.
+..#.##.####.##.
+.#.############
+.#.#..#....#..#
+###....####....
+#..###..##..###
+....##..##..##.
+
+..###.###
+####..##.
+.##...##.
+#..#.....
+.###.####
+....#####
+####.#..#
+####.#..#
+....#####
+.###.####
+#..#.....
+
+####.##.##...
+.#...#..#..#.
+..##....#.#..
+.#.###....#..
+.#....##..##.
+....##.##....
+..#.#...#####
+..#.#...#####
+....##.##....
+.#....##..##.
+.#.##.....#..
+..##....#.#..
+.#...#..#..#.
+####.##.##...
+####.##.##...
+
+###..#.#..#
+#...#..##..
+#...#..##..
+###..#.##.#
+###..#.##.#
+#...#..##..
+#...#..##..
+###..#.#..#
+#....#####.
+...#..#.#.#
+..##.##...#
+.#..#..##..
+.#....#.#..
+...##.###..
+..#....####
+
+....#.##...
+####..####.
+###.###.#..
+..#..##....
+....#.##.##
+....#.##.##
+..#..##....
+###.###.#..
+####..####.
+....#.##...
+..#......#.
+..##.#.###.
+..##......#
+#.##.####.#
+..#...###..
+
+#.##...####
+.##.##.#..#
+#..###..##.
+.###.......
+...#.#.####
+#..####.##.
+#..#.##.##.
+
+#...##.
+.#..##.
+.#.....
+.###..#
+.###..#
+.#.####
+..#####
+.#.....
+..##..#
+#...##.
+#.##..#
+..##..#
+#...##.
+
+.##..#..#....
+.#.##...##..#
+#...##...####
+####........#
+#.##...#.####
+........#....
+#.#..####.##.
+#######.#....
+#######.#....
+
+...###...#..#.#
+####....##.#.#.
+##....##..#....
+###....#..#...#
+###....#..#...#
+##....##..#....
+####....##.#.#.
+...###...#..#.#
+..##..##....#.#
+####....###..#.
+#..###.....#..#
+##.#.#.#..###.#
+..####.#.####.#
+...#..###...##.
+..######.#..##.
+
+#####.##.#..#
+######.#.#.##
+##...#.#...#.
+##...#.#...#.
+######.#.#.##
+#####.##.#..#
+##.###..#.#.#
+....####.....
+.#..#.##.#.##
+
+##.....##..
+...##......
+##....####.
+###.#.#..#.
+.....##..##
+..#.#.####.
+.....##..##
+##.....##..
+##....#..#.
+###.#.####.
+##...#....#
+###.#......
+#.#########
+####...##..
+..##.#....#
+#####......
+......#..#.
+
+.#.######.##.
+.#.##..##.#.#
+#.#......#.#.
+#.##.##.##.##
+#...#..#...#.
+...#....#...#
+.#........#..
+##...##...###
+#.########.##
+#.#.####.#.#.
+.#.#.##.#.#..
+.#.#.##.#.#..
+#.#.####.#.#.
+#.########.##
+##...##...###
+.#........#..
+...#....#...#
+
+##.##.##..##.
+##....#######
+###..###.#.##
+###..###.#..#
+#..##..#.#..#
+.#....#.#.##.
+.#....#.#.##.
+...##....#..#
+###..###.#..#
+
+#####.##.
+###......
+..#...#.#
+....##...
+####.##.#
+####....#
+####...##
+####.##.#
+....##...
+..#...#.#
+###......
+
+##......##.#.
+..####...#...
+##.#.##..#..#
+##.#.##..#..#
+..####..##...
+#...#..##.###
+#...#..##.###
+..####..##...
+##.#.##..#..#
+##.#.##..#..#
+..####...#...
+
+#..##.#
+#..##.#
+.#..#..
+.#..##.
+..#####
+#.#....
+....###
+....###
+#.##...
+..#####
+.#..##.
+.#..#..
+#..##.#
+
+......###
+#..##.#.#
+#..##.#..
+......###
+#..#...#.
+......###
+....#.##.
+.##.#....
+......##.
+####..#..
+#..#####.
+#..##....
+#..#.###.
+....#.#..
+.##.#####
+.....#.#.
+#..##.##.
+
+..##..#####..##
+##..#######..##
+..#.###.###..##
+##.##..#..#.##.
+##.#..###.#..#.
+...#.##.##....#
+..#..#.##..##..
+####...#.......
+...###.#...##..
+...#.....##..##
+##.........##..
+####....#......
+##..#..##.####.
+###...#.#.#..#.
+##.##.#...####.
+##.###..##.##.#
+##.####........
+
+######......#####
+##.#..##..##..#.#
+##.##........#..#
+###.#........#.##
+##.##..#..#..##.#
+##.....####.....#
+...#.########.#..
+###..##.##.##..##
+###............##
+..#.##......##.#.
+......#....#.....
+
+.#.#.#.##...###.#
+.###....###..#.#.
+.......##..#.#..#
+......#..#..#..##
+#.....##..#######
+..#..#.##.##..##.
+.#.....###.#...#.
+##.##.#..##..####
+##..#.#..##..####
+.#.....###.#...#.
+..#..#.##.##..##.
+..#..#.##.##..##.
+.#.....###.#...#.
+##..#.#..##..####
+##.##.#..##..####
+.#.....###.#...#.
+..#..#.##.##..##.
+
+..##.####
+..##.####
+#.#######
+#####...#
+####..##.
+.###.####
+##.#.....
+##.#.....
+##.#.####
+#.#.##..#
+####.#..#
+
+.#..##....##...
+.#..######..###
+.#.###.########
+.###....##..##.
+.###...........
+.#....#..#..#..
+##.############
+..#..##...##...
+.#.#......##...
+#....##..#..#..
+.##..#.........
+
+##..####..#####
+....#..#.......
+#....##....####
+.####..####....
+##..#..#..#####
+#...#..#...#..#
+.#.#.##.###.##.
+##.######.##..#
+##.#....#.##..#
+...#.##.#......
+.#.#.##.#.#.##.
+...#....#...##.
+.###.##.###....
+
+##...####..
+#..###.###.
+.##.#.#....
+.#..##.#..#
+.#..##.#..#
+.##.#.#....
+#..###.###.
+##....###..
+.#...#.##.#
+.#...#.##.#
+##....###..
+#..###.###.
+.##.#.#....
+
+.##.#.#..
+.....###.
+....#.#.#
+#..####.#
+.##.#.###
+#..##.#..
+#..##.#..
+.##.#.###
+#..####.#
+....#.#.#
+.....###.
+.##.#.##.
+#..##....
+#..####.#
+....####.
+
+..#.###
+...#...
+...##..
+##....#
+....#..
+###...#
+###..#.
+#####.#
+......#
+......#
+#####.#
+###..#.
+###....
+....#..
+##....#
+
+..##..#
+.####..
+##..##.
+.####..
+#.##.#.
+#.##.##
+.####..
+
+########.##...##.
+..####......#####
+.######.####.#..#
+###..#####...####
+..#..#..##.#.####
+#..##..#.....####
+.#.##.#.###......
+##....######..##.
+#########.##.##.#
+
+.#.#..#
+#.#.##.
+.##.##.
+.#..##.
+#.#.##.
+.#.#..#
+.###..#
+.##.##.
+#......
+
+.####.....#
+.#..#..#.#.
+.##.#...###
+#.##.###...
+..##..###..
+#######.#.#
+..##..##.##
+##..##...##
+##..###..#.
+#.##.#...#.
+#.##.#...#.
+
+####..##.#.
+...#.....#.
+##.#..###..
+######.....
+###..#...#.
+###..#...#.
+######.....
+##.#..###..
+...#....##.
+####..##.#.
+###.######.
+##....##.##
+##.###.#.#.
+
+.#..#..####..#.
+#..#..........#
+#.##..........#
+.#..#..####..#.
+###.##.#..#.##.
+####.###..###.#
+...###.####.###
+.#....#....#...
+##..##..##..##.
+
+....#..
+#####..
+.....##
+.....##
+.##.#..
+.##.###
+####.##
+....###
+....#..
+###.#..
+.....##
+####...
+.##.###
+.##.###
+.##.#..
+
+#.######.##..
+.#.####.#.###
+###########..
+##..##..##.##
+##.#..#.###..
+####..#####..
+..#....#..#.#
+.#.####.#.#..
+##......##...
+...........##
+#.######.#...
+#.#.##.#.#.##
+#.##..##.#...
+.#.####.#..##
+#.##..##.####
+.#..##..#.#..
+#...##...####
+
+###..#..##..#..##
+..####......####.
+..#.#.#....#.#.#.
+...#.#......#.#..
+##.#.###..###.#.#
+..##...####...##.
+##..#.##..##.#..#
+..#.#..#..##.#.#.
+.....##.##.##....
+##.##.#....#.##.#
+##..##.####.##..#
+
+#####..
+.###...
+.###...
+#####..
+....###
+#...###
+##.#...
+#...#..
+.....##
+###.###
+#.#.#.#
+.##..##
+.#.#.##
+.##.###
+###....
+#.###..
+##..###
+
+..###..#.
+..##...#.
+..#.#.##.
+...##....
+..#..#..#
+..#.#####
+##..#.#.#
diff --git a/src/day_13.rs b/src/day_13.rs
new file mode 100644
index 0000000..94b2d6c
--- /dev/null
+++ b/src/day_13.rs
@@ -0,0 +1,219 @@
+use std::ops::{ControlFlow, Range};
+
+use crate::{Problem, Solution};
+
+pub struct Day13;
+
+impl Problem for Day13 {
+ const DAY: u8 = 13;
+
+ const INPUT: &'static str = include_str!("../input/day_13.txt");
+}
+
+impl Solution for Day13 {
+ type Answer1 = usize;
+
+ type Answer2 = usize;
+
+ fn part_1(input: &str) -> anyhow::Result<Self::Answer1> {
+ let chunks = input
+ .trim()
+ .split("\n\n")
+ .map(std::str::FromStr::from_str)
+ .try_collect::<Vec<Chunk<0>>>()?;
+
+ Ok(chunks
+ .into_iter()
+ .flat_map(|chunk| chunk.process_chunk())
+ .sum())
+
+ // 32663 <
+ // 33975 ==
+ }
+
+ fn part_2(input: &str) -> anyhow::Result<Self::Answer2> {
+ let chunks = input
+ .trim()
+ .split("\n\n")
+ .map(std::str::FromStr::from_str)
+ .try_collect::<Vec<Chunk<1>>>()?;
+
+ Ok(chunks
+ .into_iter()
+ .flat_map(|chunk| chunk.process_chunk())
+ .sum())
+
+ // 29083 ==
+ }
+}
+
+type Predicate = fn(&[Vec<char>], &mut usize, usize, usize) -> bool;
+
+struct Chunk<const N: u8> {
+ inner: Vec<Vec<char>>,
+}
+
+impl<const N: u8> Chunk<N> {
+ fn process_chunk(&self) -> Option<usize> {
+ self.find_items(0..self.inner.len() - 1, |v, s, i, j| {
+ *s += v[i].iter().zip(v[j].iter()).filter(|(l, r)| l != r).count();
+ i == 0 || j == v.len() - 1
+ })
+ .map(|i| i * 100)
+ .or_else(|| {
+ self.find_items(0..self.inner[0].len() - 1, |v, s, i, j| {
+ *s += v.iter().filter(|line| line[i] != line[j]).count();
+ i == 0 || j == v[0].len() - 1
+ })
+ })
+ }
+
+ fn find_items(&self, mut range: Range<usize>, pred: Predicate) -> Option<usize> {
+ range
+ .find(|index| self.check_chunk(index, pred))
+ .map(|i| i + 1)
+ }
+
+ fn check_chunk(&self, index: &usize, pred: Predicate) -> bool {
+ match self.check_item(index, 0, 0, pred) {
+ ControlFlow::Break(is_valid) => is_valid,
+ ControlFlow::Continue(_) => unreachable!(),
+ }
+ }
+
+ fn check_item(
+ &self,
+ index: &usize,
+ width: usize,
+ mut state: usize,
+ pred: Predicate,
+ ) -> ControlFlow<bool, usize> {
+ let i = index - width;
+ let j = index + width + 1;
+
+ let term = pred(&self.inner, &mut state, i, j);
+
+ let state = if state > N.into() {
+ ControlFlow::Break(false)
+ } else if term {
+ ControlFlow::Break(state == N.into())
+ } else {
+ ControlFlow::Continue(state)
+ }?;
+
+ self.check_item(index, width + 1, state, pred)
+ }
+}
+
+impl<const N: u8> std::str::FromStr for Chunk<N> {
+ type Err = std::convert::Infallible;
+
+ fn from_str(s: &str) -> Result<Self, Self::Err> {
+ Ok(Self {
+ inner: s
+ .trim()
+ .lines()
+ .map(|l| l.trim().chars().collect::<Vec<_>>())
+ .collect::<Vec<_>>(),
+ })
+ }
+}
+
+impl<const N: u8> std::fmt::Display for Chunk<N> {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(
+ f,
+ "{}",
+ self.inner
+ .iter()
+ .map(|v| v.iter().collect::<String>())
+ .collect::<Vec<_>>()
+ .join("\n")
+ )
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ const INPUT_1: &str = indoc::indoc! {"
+ #.##..##.
+ ..#.##.#.
+ ##......#
+ ##......#
+ ..#.##.#.
+ ..##..##.
+ #.#.##.#.
+
+ #...##..#
+ #....#..#
+ ..##..###
+ #####.##.
+ #####.##.
+ ..##..###
+ #....#..#
+ "};
+
+ const INPUT_2: &str = indoc::indoc! {"
+ #.##..##.
+ ..#.##.#.
+ ##......#
+ ##......#
+ ..#.##.#.
+ ..##..##.
+ #.#.##.#.
+
+ #...##..#
+ #....#..#
+ ..##..###
+ #####.##.
+ #####.##.
+ ..##..###
+ #....#..#
+
+ .#.##.#.#
+ .##..##..
+ .#.##.#..
+ #......##
+ #......##
+ .#.##.#..
+ .##..##.#
+
+ #..#....#
+ ###..##..
+ .##.#####
+ .##.#####
+ ###..##..
+ #..#....#
+ #..##...#
+
+ #.##..##.
+ ..#.##.#.
+ ##..#...#
+ ##...#..#
+ ..#.##.#.
+ ..##..##.
+ #.#.##.#.
+ "};
+
+ #[test]
+ fn test_part_1() -> anyhow::Result<()> {
+ Ok(assert_eq!(405, Day13::part_1(INPUT_1)?))
+ }
+
+ #[test]
+ fn test_part_1_2() -> anyhow::Result<()> {
+ Ok(assert_eq!(709, Day13::part_1(INPUT_2)?))
+ }
+
+ #[test]
+ fn test_part_2_1() -> anyhow::Result<()> {
+ Ok(assert_eq!(400, Day13::part_2(INPUT_1)?))
+ }
+
+ #[test]
+ fn test_part_2_2() -> anyhow::Result<()> {
+ Ok(assert_eq!(1400, Day13::part_2(INPUT_2)?))
+ }
+}
diff --git a/src/lib.rs b/src/lib.rs
index b7ecf0d..abf433e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -20,6 +20,7 @@ pub mod day_09;
pub mod day_10;
pub mod day_11;
pub mod day_12;
+pub mod day_13;
pub trait Problem {
const DAY: u8;
diff --git a/src/main.rs b/src/main.rs
index fa082b4..f7dd64e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,7 +1,7 @@
use aoc_2023::{
day_01::Day01, day_02::Day02, day_03::Day03, day_04::Day04, day_05::Day05, day_06::Day06,
day_07::Day07, day_08::Day08, day_09::Day09, day_10::Day10, day_11::Day11, day_12::Day12,
- Solution,
+ day_13::Day13, Solution,
};
fn main() -> anyhow::Result<()> {
@@ -17,6 +17,7 @@ fn main() -> anyhow::Result<()> {
Day10::solve()?;
Day11::solve()?;
Day12::solve()?;
+ Day13::solve()?;
Ok(())
}