summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Wernick <justin@worthe-it.co.za>2023-12-12 08:55:31 +0200
committerJustin Wernick <justin@worthe-it.co.za>2023-12-12 08:55:31 +0200
commit89df248a74b58ba075873cdf8230f08bd9405a89 (patch)
treedaf33005bb81f9aa234f5b9e77387b471b94aac2
parentd18401b095f654e1eea43a34bf897e6e1b88eea5 (diff)
Day 12 part 1
-rw-r--r--2023/inputs/day_12.txt1000
-rw-r--r--2023/src/bin/day_12.rs124
2 files changed, 1116 insertions, 8 deletions
diff --git a/2023/inputs/day_12.txt b/2023/inputs/day_12.txt
new file mode 100644
index 0000000..70fe960
--- /dev/null
+++ b/2023/inputs/day_12.txt
@@ -0,0 +1,1000 @@
+.???#??.?##?#??? 1,1,7
+#.???###???#????. 1,5,2,1,1
+??.?#??##??.##?##.? 7,5
+??????#???????? 7,2
+????.##???????????.? 3,10,1,1
+?????#????#? 2,1,1,1
+?#?.#????.? 1,1,1
+????#?.?..????# 3,4
+?????????##????? 1,9,1
+???##????.#???#? 7,1,3
+.?.???#????????? 2,4
+?#???#.???.??????. 2,1,1,1,1,4
+?..??#????#???#?### 11,3
+???#?..?#?#? 3,3
+?##???????????#??# 6,2,2,1,2
+????.#?.???#??? 1,1,2,3,1
+???..?#??? 1,4
+?????#?#??#??. 1,3,2
+???#???.???#? 2,1,1,2
+?#?#?????????????.?. 8,1,1,1,1,1
+?????????#???.#.? 3,3,1
+???#??.?#.? 3,2
+??????.##?# 5,2,1
+???????.?? 2,1
+?????.??#????? 3,3,2,1
+#?#???.?????###?#? 6,3,6
+?#????##??#?????#?. 1,12
+?#?#?.?#???.? 4,4
+.#?????#?####??????? 3,9,2
+???#???#?????#??? 1,2,11
+.?#?.??.?.?.?. 2,1,1,1
+????#.??#?#??.??.?? 5,5,1
+?.#?#??##?#? 3,4
+?##?.??#??? 3,4
+?????????##?#. 4,7
+.?.#???.??###???? 1,1,1,6,1
+.##??#?????????#? 5,2,1,3
+.??#?.??.??. 1,2
+.??#????##??? 1,3,2,1
+#?????..?#??..?. 1,1,1,4,1
+.?#?????#???.? 8,1
+.#?.???.???#?#??#.? 2,1,1,7,1,1
+?#.???#.??#??#???? 1,1,1,1,8
+#??##?.?#? 1,4,1
+?.#???.?.?????? 1,3,1,1
+?.??#??.??#.?# 5,3,1
+??#?###???#? 7,3
+???#????????#?. 7,2
+.#???????# 1,1,1
+.??????????#.??.? 4,1,1,1,1
+?#?.??.#.. 3,1,1
+#?...??.#?? 2,1,1
+???.???.???#? 1,1,1,3
+##?#?#?????????.?.#. 2,12,1
+.?#?????..???.?? 7,1,1
+.#???#??#??.#.???#?? 9,1,5
+?#??.????#.????#??# 2,1,3,2,3,1
+.?.??#?.??.?##???# 1,2,1,4,1
+?.#?????#?#?????? 9,1,1
+.?????.#????.??? 1,2,3,1,2
+.?????.?#???? 1,4,1
+?#?????#????????? 10,1,1,1
+.#????????#?. 2,1,4
+?????????.??.?? 8,1
+????#??#???. 3,1,1,1
+.???#.???##.?#?? 3,4,2
+.#?.???#?.???#? 1,1,2,1,1
+??#?.??##??.#????.?? 3,3,1,1,2,1
+..#..??##??.?? 1,4,1
+?#?.??#???#?##?##? 1,2,9
+????##??.#..??????.. 6,1,2,1,1
+?#?????#?????###???? 4,13
+?#?##..?#????#?????# 4,1,1,4,2
+.?.????????#??? 1,1,5
+?.?#???????##?#???.. 2,6
+????..?????##.?..?? 3,6,2
+..?#???#..? 2,1,1
+??????..???????? 3,2,4,1
+??#??##.#.??# 1,5,1,2
+????.?.???#?. 1,1,1,4
+.?##??##???#??? 2,7
+?????????? 6,1
+.???#?##????#.? 5,3
+?#??.??????? 4,2,1
+????????#?#? 1,2,6
+??#???????.???? 8,2
+???#?#?????????.? 3,1,2,2,1
+?.???????. 2,1
+?.??.#???####??#.. 1,2,2,8
+??#?????#.#????. 1,4,1,2
+?####????.. 5,2
+.???#?.?.#????#? 2,7
+.#?###.?#?? 1,3,2
+??????#??#???#? 3,2,3,2
+.?###?????? 5,3
+.#..?????? 1,2,1
+???#..?.#???#? 2,1,1,6
+??#?#???.? 1,1,1
+.?#????##?##? 1,6
+#?#?#.?????????#.? 5,3,2,1
+.??##?????? 4,2,1
+??##??.??. 4,2
+??#???????????# 2,1,4,1
+???.????#?????? 2,1,1,1,1
+.???#??#?.?????. 5,1
+.##?.??.?#.# 3,1,1,1
+?#?????#?#???##????? 2,11,1,1
+..??.#??#??#?#????#? 1,1,7,1,1
+???.?##?#??? 1,1,5,1
+???#?##???##???????? 2,13,1
+..?????##?..##???? 1,2,6
+???#??##??#??#?????? 8,3,2
+#?#??#.???..??#? 1,4,2,4
+??#??.????????#?? 4,2,1,1,1
+.#??.????.. 2,2
+..?????##??#?#?#???? 7,7
+#?#???#??.??.??#?.# 1,5,1,1,4,1
+.?#?##???.?.. 5,1
+?????.?.#? 2,1
+.??.???#??#???##?#?? 1,2,1,7,1,1
+?????#.?.?????#??? 1,1,1,1,4,4
+???.?..#??.?? 1,3
+???????##????#?#?## 2,6,6
+?#?????.?? 5,1
+??##?.#?..#??? 2,2,1
+#.????????#?? 1,5,4
+???###??????##???#? 12,2
+?.????.??#?????..?. 4,1
+????.???.? 1,1
+??#..???###??.?#.# 2,1,4,1,1,1
+.?????#?????? 8,1,1
+??#?##.?.??. 4,1,1
+.??????#??#???.?? 6,3,1
+??.??.????#??.? 1,2
+???????.##????.#.??# 3,2,2,1,1,1
+??.??#???.. 1,5
+?????????????#???? 2,1,3,1,3,1
+#?.??????????#.?? 2,1,2,5,1
+?#????#?#.?.??#???? 7,1,1,1,1,1
+????.?????.???#???? 2,5,6
+??.?????#??.???? 5,1
+??#????.##.??????#?. 6,2,7
+#..?#???.?.? 1,3
+.#??.???.?# 2,3,1
+????????#?#?? 1,3,1,2
+?##?##????#?#.??? 8,2,1,2
+.???#.?.??.????.. 4,1,1,4
+.??##??????#???????# 1,2,8,1
+.?#..??##?????# 1,1,2,1,1
+?.#?.##??????#??? 1,11
+.???#?????#? 3,1,3
+####?#?#?#??? 8,1,1
+.??#?#?..#??. 6,1
+###????.???#? 4,5
+.?.??####?#???#???. 8,4
+.??#???#?####.?? 1,1,7
+?.#?.??????#????.? 1,6
+??????##??#??.?.???? 11,1,1
+?????????#. 4,2
+??.???.?#.? 1,1,2
+?.??#???#??? 2,3
+?..??????.????##? 5,5
+.???.???#???#???? 1,10
+?..#???.????#? 3,5
+?????.?#??????? 1,1,1,1,2
+?.?#.?????.? 2,3
+.?#?##?.#??? 4,2,1
+?#??#??##??.? 1,3,3,1
+?#?.?#?..#???.#.???# 2,2,3,1,1,1
+???..#????????? 3,1,1,3
+???.#.?.?? 1,1,1
+.##???#??##.?? 2,6,1
+??????#??????#?? 2,1,2,1,5
+????.??###?#?#?? 1,8
+?#?#.?#????. 2,1,2,2
+??#.?#??????????.??? 3,4,1,2,2
+?????..??#??.????#? 1,2,1,3,1,3
+.????#???#?? 5,4
+?..#???.#?#?. 1,2,4
+#??????#?.?.???.?? 1,1,2,1,1,2
+??#.?#????.?#?. 1,3,2
+?##??#??????.#.?.?#? 11,1,1,1
+??##????#??. 2,3
+#????##??..??? 1,7,1,1
+.??????##?. 1,6
+.??.???????????. 3,4
+?#.#.#??#?.? 1,1,4,1
+#.??###??#?.#?.???#? 1,1,6,1,1,1
+??##??.?#?.#????.?? 5,1,3,1
+.????.#???..? 1,1,4
+?.?.#??#?##?#. 1,7,1
+????#.#??????.??? 1,1,7,1
+.#?????.###?????# 1,3,7,1
+??###??#?. 4,3
+?????#??.??.??? 1,6,1,3
+???.??#??#??? 2,6
+.##?..?#??? 2,1,1
+.#?#???????? 3,1
+???#?#?#.?.??#??.# 7,1,4,1
+??????#???.????.???? 1,3,1,4,2
+.?#?????#?#?????. 3,1,5,2
+?.#?###??#?#?.? 1,10,1
+.??.?.#??????##?#?? 1,1,2,1,1,4
+????#?.?#. 1,1,1
+????#???#???.? 3,3
+.??#?.???###???? 3,1,3,1
+??...????##? 2,1,5
+.??#????.????..?..? 2,1
+??##.#.#?.?. 4,1,2,1
+???#?###.??.?##??#?? 5,6,1
+.?...##?#?????.###? 1,8,3
+?#??#?#....?.?#?.??? 6,1,3,1
+?.?.??#???#?.. 1,8
+?.????#?#??#..#?? 8,1,2
+#?#??#?..??.????#? 6,2,1,1
+?..#???#?#???#?.?.#? 1,1,5,1,1,1
+?.?#????#????#? 1,4,3
+?.?????.??? 2,1,1
+???????????.???#???? 1,1,2,3,3
+?????????###.? 4,5
+??????#?#?##??#? 9,5
+.???###?.##??.?. 5,3,1
+?#??????#.#???#??.? 6,1,1,2,1
+???#??..??#????. 6,4
+????.??????#??????? 1,1,3,4,1
+????????###??????#. 1,2,7,4
+##????#?#????#????.# 9,7,1
+???#?#?#????#???? 5,6,1
+?#????#??#?##???# 6,1,2,1
+?????.????????????# 1,2,9
+?.#?.?#.#??? 1,2,2
+?###?#???????.# 6,3,1
+??#???#?.?#????? 4,2,3,3
+.?#?#???#. 4,2
+.?????.???##????? 2,5
+?#?.?????#??? 2,2,4
+??#????#??????##??# 10,7
+?#?.???????#?#?.??. 2,1,2,5,1
+?#?#..???##??#??? 3,10
+.?????.?#?.??#??? 1,1,1,6
+?????????#?#???.. 1,4,4,2
+?...?##?.? 1,3
+?#??.???.??# 3,1,2
+?#??.???????#???.?? 3,2,7
+.??#..?##???#? 2,4,2
+.??????#??.????? 3,3,1,2
+#????##?#? 3,5
+??#?????#??????..?? 2,8,1,2
+?????.????? 3,2,1
+??.?.##?.?#? 1,2,2
+???##??#??##??? 6,1,3,1
+#??#???.???.? 1,2,1,1
+.?????.?#???? 4,1,1
+????????..?#??.?? 3,1,2,1,2
+..??#?#.?. 1,1
+??#???#?.#? 7,2
+????????#?#.??? 2,7,2
+?#?..????.. 1,2
+???????#?. 1,5
+??????.?#??####?. 3,8
+?##?#??.?##?#?? 4,7
+?????.?.#??? 1,1,3
+?#?????.??. 5,1
+??.?#??###?. 2,1,5
+.?#.?#?.???. 2,2,1
+???#.??#????? 1,4,1
+?.#??????#.?? 3,1
+..?.#??##?#????????. 10,1
+..??#?????? 3,1,1
+#??.??#???#?#??????? 2,3,5,1
+?##.#?.??##?#? 3,2,6
+?????#?.????? 1,5,4
+?#??????.? 4,2,1
+.??#.????? 2,1
+?????#???..?? 8,1
+?#??????.?#?##??? 3,1,8
+????#???..? 2,2
+#?#.??#???#???.?#? 1,1,1,6,1,1
+????#?????????#???? 1,6,9
+????#?####???.?? 3,7,1,1
+??????#?#..#??? 1,7,1,1
+.???.??#????# 1,8
+??????##..?? 5,2,2
+.????....###??#???.? 4,8
+???..????#???.??# 1,1,3,1,1
+??#??????? 5,1
+?????.?##????.??#?#? 4,2,1,6
+.???#?.?#?????#?? 2,2,2,1,3
+?#??#?#?#. 6,1
+?????????#????#?.#. 1,1,1,8,1
+#?.????.????. 1,2,1,1
+?.##??????##. 1,10
+????.??#??#?..?# 3,3,3,1
+??#.?#???.??? 1,1,1,2
+????.#.????##.?.?#?? 1,1,6,1,4
+????#???#?#???#?## 1,9,4
+??.#??###?. 1,7
+#??????????.?????? 3,1,1,1,4,1
+.???#.????????##???. 3,11
+????????.??? 1,1,1,1
+?#?.??.??. 3,1,1
+??#..???## 2,2,2
+??????.???? 1,1,2
+.?????##???.##??? 4,4
+?.#?????#??? 2,1
+#??##?#???#?#???#?#. 9,5,3
+??.???###??.???? 1,7,2
+??#????#?.? 2,1
+????...?#?????# 1,7
+.#?.??####??#.?? 1,8,1
+???.#???.#???#..?? 1,3,1,1,1,2
+??#?.##?#?##? 1,8
+????????.#??????#??# 2,3,11
+??.?#??.#??????. 3,5
+????#?????.?? 3,3,1,2
+.????##???.??#...? 8,1
+?#.???????? 1,3,1
+???..#?????##???#?? 1,10,1
+?????????.?#????? 1,2,2,4,1
+##????#?#???#?.#.# 4,2,2,2,1,1
+???????.#????.#??##? 1,4,1,1,1,4
+?.???#??#??.#. 1,6,1
+?#?#???..#?.#??.? 6,1,3
+??###?#???.??? 1,8,1
+????????..???? 2,2,1,2
+.#??#??????#???? 1,6,1,1,1
+#.?#...??##???.?##?? 1,1,1,4,3,1
+.?###?####????.???? 11,2
+?.???.??.???.?? 1,2,2,2,2
+?##?#??#??.?.???? 9,2
+.?#..?..####.??#? 2,1,4,2
+.#???.#??.? 3,2
+#????.#????? 2,1,1,3
+??#.???.??? 2,2,1
+?????????#?# 5,4
+??????#?###???????? 14,1,1
+????.?#?#? 1,4
+..??#????#? 1,6
+?.?#????#???#.#?? 4,6,3
+.#?#?#?#??.?# 1,1,5,1
+#????????#? 1,2,5
+??#???.###???#????? 3,7,2
+.##?#??????#????.##. 14,2
+??????????#..?? 1,7,1,1
+??.?#????.? 5,1
+????#?..?? 1,2,1
+??.??#????? 1,5,1
+??##?#??.?#? 8,1
+.??..#??.??#?. 2,1,3
+???.??????#?#?.?.??. 1,1,1,6,1,2
+??.???##??.#????? 1,6,1,1,1
+.?????#??# 1,1,1
+..??.?#?#???? 1,1,2
+??.?????#???. 1,7
+??????.???????#.? 3,1,1,5
+.???????#? 1,3
+?#????.?.?#??.? 4,1,1,1,1
+.#??????????#... 4,1,1,2
+????.??.?##??#??. 2,8
+???#???.???#?..? 5,1,1,1
+#??#?#.?????????# 2,3,1,1,4
+.#.??#??#?#??#?#. 1,6,6
+?????##?#???. 1,6,1
+????????.??. 1,1,3,2
+????###???.#?#???? 7,6
+??#???##?.#?#?.## 1,1,4,3,2
+?#?.##???. 1,3,1
+???#???????#?#??. 7,3,1
+??.?#.?..???????# 2,2,1,5
+#.?.#??.?? 1,3
+..??#??.?? 3,1
+.??#?.???#?#?? 1,8
+..?.?.???.???? 3,1
+???#?##?#?#?.?#???? 10,2
+??..?#..??#?? 1,4
+????.?.??..##??##??? 2,1,1,9
+??##?????.????#?.?? 6,5,2
+???#????????#.?#.?# 1,10,1,1
+????.?###?? 1,4
+.#?.?????? 1,2
+?..?.???#?#?#?#? 1,9
+????.?#???????. 4,1,1,2
+????#?##?.???? 8,2
+?????.#??? 1,1,1
+.???#?.#??.? 1,3,3,1
+#?##??#?.?#?.???? 4,2,2,1
+.?#???.??? 1,2,1
+???????#?# 2,2,1
+?#??.???#???????#.? 3,4,1
+.????#????????#???? 8,3
+#??#?##.?. 2,4,1
+????.?????##?? 1,1,2,4
+?????#?#?.????##???? 2,5,1,3,2
+???????#???##?.#?? 1,10,1,1
+.?.???????#???#???? 1,1,1,1,1,5
+????##???#..??.#??#? 1,6,1,2,1,2
+?#????????????#?? 6,3,4
+.?.?#?????. 1,3,2
+.????#?????? 1,3,1,1
+??.####???##?????? 11,1
+??????#....???#????? 2,5
+?#.#.#?#?#??#?#?. 2,1,11
+?.#????#.#?#?. 2,2,4
+#??#??.##?#?##?????. 2,1,1,4,4,2
+???????????.??# 1,1,2,1,2
+???.?#???#?#????#?.# 3,4,1,2,2,1
+#?#?.?????????? 4,1,3,3
+?????#???? 2,1,2
+?#?.#.?#??#??#.? 2,1,8
+?###??..????#?? 6,5,1
+..?##???????# 6,1,1
+?#???????.??#???? 1,3,4,1
+.????.???????? 1,7
+.?????.????#.??? 3,1
+#.???##?#??# 1,9
+.????#?.#????.?? 2,2,1,3,1
+?##?????#??? 4,3,2
+?#????.?#?? 2,2
+??#.?????????.##??? 1,1,1,2,1,5
+.???#???###?##?##??? 16,2
+????#.???#???? 2,6
+.??##?##?#?. 1,2,2,2
+??????..#??#####??? 2,8
+#.????..??#????. 1,1,1,7
+?##???#?.?#??#.? 5,2,1,1,1
+?##?#?#..????..?. 6,4,1
+?????#??#. 1,6
+#???.##??? 2,3,1
+?#??????#???????? 1,5,1,1,1
+?#?#?.??##??#.??.??? 5,4,2,1,2
+??#?????????..???##. 10,5
+???.??##??????##?## 1,13
+#??#.??#.#?#??#.#?# 4,2,6,1,1
+??.??#?????? 1,5
+???##??????.? 6,2
+??.???.??. 1,2,1
+.?????#???? 5,1
+??.??.??????. 1,3,2
+??##.?.????? 3,3
+.?#??#??#??.???. 5,2,1,1
+?#.##?????.?.?? 1,2,2,1,1
+??.##????????..??#?? 5,3
+?.??????#.#? 3,1,1
+.?#???.?#??#?##.?. 4,4,2
+??????#?..???. 4,1,2
+?.???#???#? 1,5,2
+?#????#??????#????? 2,3,5,1
+????#?.??#?? 1,1,3
+??###??????## 4,1,4
+##??#????..##??? 2,1,2,4
+????.????..? 2,1
+#????.??????.??? 2,1,4,1,1
+???????##?.? 1,3
+?.#??##.?.#.##?.?.?? 1,1,3,1,3,1
+?#.??.??????#???.??# 1,1,2,5,3
+.#????#?????.???? 1,1,2,3,2
+????..#??#????#? 1,6,2
+.##?????#??#??##?? 4,2,6
+?#????.??.?#?#?.??? 5,2,5,3
+????????????#?? 2,1,1,1,3
+.??.??#?????#? 1,2,5
+??.#??.?#?????? 2,7
+???##?????####???.?. 1,2,9,1
+.???.#?.???#???# 2,6
+?.????##????. 1,7
+???#?#?.?.?#?????.? 4,5
+?.?.?#.????? 1,2,1,1
+??.???#?..#? 2,2,1
+#?#.#??#?..?.????? 1,1,5,1,1,2
+???#?.??.?#.?# 2,2,1,1
+?.??#?.????.?? 1,2,2,1
+???##?.???#?? 1,2,5
+???.???????.. 1,5
+#??#????#????????# 1,3,2,2,1,1
+.????#??#? 1,5
+?#????.#?# 4,3
+?.??????.?.?#??.?#?. 5,2,2
+.#??????#????# 1,1,4,1
+???#???#??????#??.? 2,10
+#?.?#?.???????#?.?? 1,2,5,3
+?#.??.#???##??#.#..# 1,1,1,5,1,1
+???#.??#?. 1,3
+.????#?#?###?#?#. 13,1
+??.##??.?#???.???. 4,3,2
+?#?#.##?.????#?#? 3,3,2,1,1
+??##???#?#?##.??. 11,1
+?????#?#???#???.? 2,1,4,1,2
+.#?.##???????##. 2,2,2,3
+?#??????###?? 2,5
+.??#???##???.???#.?? 8,1,4,1
+.??#????.??#???. 1,3,4
+?#????.?.????#?.?? 1,1,1,2,2,1
+?..##?#...??.##?. 1,2,1,1,3
+#?????##???#?????#?? 3,7,3,2
+.???##?????#???#.??? 4,1,1
+??..???#?????#????.? 1,13
+??##?????#????.?? 1,12,1
+.?.?#.?#????. 2,3,1
+??.???#??????? 1,10
+???#??.??##?? 3,2
+?#??#?????.??????? 8,4,1
+?.#???#????#???????? 11,5
+#?######.??????? 1,6,1,1,1
+??????.?#?#?. 1,2,4
+???..??#?#.. 3,4
+?.??.??.#???##???# 1,1,1,10
+??#????.##???##?#.? 6,4,4
+??????.???? 6,2
+??..#??.??# 2,2,1
+.?????????.#?? 6,1
+##?..???#?#???? 2,8
+?...???#?? 1,1
+?.?#?.????????? 3,6
+#???#.##????#?#.#??? 1,1,1,9,1,1
+.???..#??#??#?#? 2,10
+#???#?.??.??.?##?#?? 2,3,2,1,2,1
+?#.?????????#???? 1,3,1,6
+?#?.???????# 2,7
+???.#????#????##?### 1,1,1,1,3,7
+??.?????????? 4,2
+?????.????#?##????? 1,1,13
+#???.????. 1,1,1
+???##????.? 4,1
+?????#?????.??#? 1,7,1,1
+.????##.?#????? 1,4,3,1
+.?.?#?##????????? 5,1
+??#?.###?#?# 2,7
+???#???#??#. 1,1,6
+????##?#??????.?#? 10,1,2
+.?#??????##?.. 2,6
+.??#?#???#? 3,1,1
+.?#?????????.#?#???? 1,1,1,1,7
+??????.?????.?????? 1,4,1,2,3,1
+.?.#?????.? 1,6
+????#???.????..??? 1,5,1,1,2
+.?...?#??.#?.?? 1,3,1,2
+???#?#????#?????.?? 3,6,3,1
+??.?????.?? 1,4,1
+#??????#???#?????? 1,1,10,1
+?????????? 3,3
+??????????# 1,6
+????????.????#? 3,1,1,1,2
+.???#?????.?#.??? 4,3,2,1,1
+????##?#????#?? 1,12
+???.#?????????# 2,6,1,1
+??#?????##.????#??.. 4,2,6
+?.???##..??#.? 1,1,2,3
+#?..????##??????? 2,11
+?????#??.??.? 5,2,1
+.?.?????????#??. 1,1,1,4
+????.????..?.? 2,1,1,1
+#?.?.?????# 1,1,3
+?.???##?#?.?.? 1,1,6,1
+?#???????????..???#? 5,2,1,1,1,3
+#????.???# 2,1,3
+#????#?#????? 8,1
+??.?#..#?..##. 1,2,1,2
+??#.?.?.??#?#???##? 1,1,1,7,3
+??#?.#.???#.??# 4,1,2,1,2
+?##????##?#?#? 3,6,1
+???#.???#???## 1,1,4,3
+.??#?????###???.? 2,1,6
+??????.??? 1,2,1
+?#??#?#?##??#? 9,2
+?.#?????????.????. 1,1,8,3
+.?#?.?#???#???#?##?? 1,14
+???????#???#?.?#??#? 1,6,2,4
+?.??#?.????#?. 1,2,6
+??????.##?.#.??#??.? 1,1,1,2,1,4
+???#.???#?#.?#???.# 4,1,4,4,1
+??..?????#??? 1,3,3
+.?????..????#??????? 2,1,8,2
+.?##??#?.??#? 3,1,2
+??.????????.??#??? 1,7,4
+????#?.#??#? 2,3,2,1
+#????##?#????#?..?? 7,3,3,1
+???##?#??.????.#?? 8,1,1,3
+??...??????#?. 1,3,3
+?#.?????????..??#? 1,6,4
+.#???#??????#?????.# 1,1,1,6,4,1
+.??##??????# 6,2
+#.?????.?# 1,5,1
+?#?.#???#?. 2,1,1
+?.??????#????#.#?? 1,4,1,1,1,3
+#?.####??? 1,7
+??.#.???#?????#???? 1,1,2,2,3,1
+??#?????#??##?##.?? 2,11,1
+?#???????.#?#??? 6,4,1
+???.#..?..#?? 3,1,1,2
+.???#?????.?#????# 1,2,1,1,5,1
+?#.?#?#?##??.???? 2,8,1,1
+????#.??#???#?#?# 1,3,2,5
+?.??.??##????##?? 1,10
+#.??#???????????.??? 1,3,4,2,1
+???????.???.?#???#? 1,2,1,3,7
+??.##??.????#??#???? 3,10
+.?#??#?#?#???.????. 2,7,2,1
+??#?#?.??#?##?.?# 1,1,1,6,2
+??#?????#??#???#. 3,11
+?#?#??#?????#???## 1,1,4,3,3
+?###?#????##??#??? 13,2
+?###?.??##??##.? 3,8
+?????????????# 7,2
+?????#?###????? 4,6
+?..???????? 1,1
+#?????..??#.?. 2,1,2,1
+???.##??#? 2,3,1
+#??#?##?#??#??#.?.? 2,6,1,2,1,1
+??????#??###?? 4,4
+????#?.????? 5,1
+?#????#????#????? 3,5,6
+????#.???? 4,4
+??????..?##??.?. 3,2
+?##???.#?#?.#.?? 3,1,1,1,1
+?#?###?#...? 2,5
+..#??????? 4,1
+?.?????##?#?????#??? 1,10,6
+#.???#?.##? 1,4,3
+????.?##?.????##?. 2,3,6
+???.#?#??##?##????.. 1,10,2
+.?????#????????????? 9,7
+?#.??#?.?? 1,3,1
+?.?..??????.?.???? 6,4
+??#.?#???.#?.?# 1,1,5,1,2
+?..#????????????#?? 1,2,11
+???#?????????#??#?? 5,10
+????????#?.???#?#? 2,4,1,1,1
+?#?????????#?.? 4,2,3,1
+.?#.??????#?? 2,2,2
+??.??#??#?????#.?. 7,2
+.??????????#.??.???# 6,4,1,1,1
+?#?#???#?#??.??# 9,1,1,1
+??#????.?.?#??.??#?? 3,2,3,4
+???##.??????# 4,1,1,2
+????#??#?#???.#?.??? 1,1,5,1,1,1
+???#?#??#?.?????? 9,1,1
+??????#???? 4,1,3
+.?#?????#??.?.??#?# 3,1,3,4
+#?.??#?..? 1,3
+?.?##??????.?.????. 4,3,2
+.??.????.???# 1,2,1,1
+???.??#???##?????? 2,7,2
+????????..????????? 4,3,4,1,1
+?#??#?#.?.?.?. 1,3,1,1
+??#?#???????.??? 1,3,5,2
+???.?.??????#??? 3,1,1,5,1
+??????????#.# 1,1,6,1
+?.????????????? 9,1
+#?#???.#?.????#???? 6,1,1,3,1
+?#??#?????? 5,1,1
+??#?#??????????#? 1,3,1,3,2
+?.?#?#???#?.? 1,5,2,1
+?..?..#??? 1,1,3
+???#.?????.?.?? 4,2,1,1
+?.??????.?? 2,1,1
+??.??#..#?# 1,1,3
+????#??.####???.?.?. 3,6,1
+?#????##?#? 3,1,4
+?.??##?????????? 6,4
+??##??..#?.?#??.? 3,1,2,4
+??#?.????? 2,1
+???????.#? 3,2,1
+??#??.????#?..#??? 2,1,1,2,1,1
+..??????.?????..? 6,1,1,1
+.???##?#?#???##??.?? 8,3
+#??????#??##?##?#??? 2,2,8,4
+#.?#??#??????.?.#??. 1,7,1,1,1
+#??#?#??????.??#? 4,1,1,1,4
+??.?#???#????.. 1,6,1
+?.??.????#????? 1,1,1,1,6
+##?????.?.#??##????? 4,1,1,5,1
+???###???????? 4,1,1
+.?#??????#??#?#?. 3,1,3,4
+#.??#??#????####??.? 1,1,1,1,8
+?#???.??#?????#. 1,1,5,1,1
+?#???????#???.? 2,2,2,1
+????????#?##?. 3,5
+?.?.?.#??..# 1,1,3,1
+###..??????..??? 3,1,2
+??????.###??.?? 2,2,4,2
+.???????#?#???#? 3,10
+.????#?#.#..?? 7,1
+?.???????#??#. 1,1,3,1
+?.?##?.?????????#?? 3,12
+.#??#.?????? 1,2,3,2
+?????##??##???# 2,4,2,1,1
+###??#??.???.?#????. 8,2,5
+?????##?#??.? 1,3,3,1
+?##??##?.#??? 8,1,1
+#?#.??#??????#??.?? 3,6,2,1
+?#???#?#??????????? 11,2,1
+...????????????.? 3,2,2
+.????#??.???.?.# 2,2,1,1,1
+.??#???#????..?##?? 2,6,4
+???##???.???? 5,1,1
+#?##?#.?.#?.?. 6,1,2,1
+.????#.#.?#?#?.#? 5,1,3,1
+??#???.??#??#??.??? 2,1,7,1,1
+##?.#.??????#? 3,1,3,2
+??#?????#???.? 3,1,2,1
+#.???..#?.???.? 1,2,2,1,1
+.??????#???.. 4,3
+????.???????#??#???? 1,1,1,1,5,1
+#.#???#????????? 1,1,1,8
+????#.?.??? 4,1
+???????.?..????#?? 1,5
+??????.????#?###? 3,8
+???#.?.??##???#???? 1,10
+???#????#???????.? 1,12
+?????#?#?##. 1,1,6
+??#?#?.??.??#??#?#? 4,1,7
+??#.#??????#????# 1,2,4,1,1
+?#??#???????.#????. 4,4,2
+?#?.???#.? 1,2,1
+?#???#??..?.? 2,2
+????.??#???#???????? 2,4,1,2,1
+??..?##???#?.#?? 7,1
+?.??.?.##?#??#?#??# 1,1,1,7,2,1
+?#?#.??????. 2,1,2,1
+.?#????.#????..?? 3,2,3,1,1
+.????..#??##? 1,1,1,2
+???.??#??????????? 3,3,5
+?#?#.?..#??#????? 3,1,5,2
+.?????#???????#? 7,3,1
+#??.???#???????.?? 1,1,4,4,1
+??.??..???. 2,1,1
+.#???.##.?#?? 4,2,4
+??..#??#??? 1,4
+??????#???? 1,1,5
+??#..???.? 1,1,1
+?##?#???..#..#??#?# 2,1,2,1,1,4
+??#.?.####?#? 3,4,1
+.?#.?#?.#.###??# 1,1,1,3,2
+.????#??#.#?? 2,1,1,1
+#?#???#?.#?????#? 1,6,1,2,1
+????..??????... 4,1,2
+???#????.???# 4,2
+#####????? 7,1
+##.?.?.?#?????? 2,4
+????.???.#?#???#?? 1,1,1,7,1
+.?#??????.???#??? 4,1,2,1,1
+?#??##?#?.##??????#? 1,4,5,1
+.????.?#????? 3,4,1
+?#.#??#????.###..? 1,6,1,3,1
+???.##???. 1,4
+..?#????.. 1,1
+..??.?.???????? 1,1
+???.???#?#?.?#?...#? 6,2,1
+?????##?#?????#? 5,1,4
+?#??????????# 1,7
+???.???????????????? 6,4
+?#???#??.???.?. 3,1,1,1,1
+??????..?#.#?# 2,2,2,3
+..??..?#????. 2,3,2
+?.?#????...???? 1,2,1,1,3
+???.#??#.?.#?#?. 2,1,4
+?????.#???????? 3,9
+#?###?#????????# 8,1,4
+???????.?# 1,1,1
+???##?.?#??#????? 5,6,1
+?.?#??.???.#? 1,1,3,1
+??.?..??????? 1,6
+??#??????#??? 2,9
+.????.###??#. 1,1,6
+??.??##?##???. 2,7,1
+???##????#??#????.? 16,1
+???#?###??#???? 1,1,4,2,1
+.???.##?.??. 3,3,1
+??????.??? 1,1,2
+?????##??? 1,5,1
+?##?#????.?#?#.. 2,3,4
+.???..#???.?? 2,1,1,1
+???????#?? 3,4
+?.?#??????? 3,1
+????.??#.#????. 1,2,1,1
+??##?#????# 6,1,1
+.#?#??..?.?? 5,1
+???##?.?###? 5,3
+????..#.???????..?? 1,1,1,5,1
+??.??????????#. 1,9,1
+##?##??.?#??? 7,1
+.?.#???#??#?????.# 1,1,10,1
+.????..???. 4,3
+##??.?#???.? 2,4
+..#?##???? 1,4
+?.?#???#?#.? 2,1,3,1
+?????????.????? 8,2,1
+?#??#?.?#?????????? 1,1,2,7
+#?????#?#??.#??? 3,1,1,1,1
+??#???#??##?.?? 8,2,1
+?.?#??????#??.?## 9,3
+.?#????.??.? 1,1,1
+?????.?.?#. 5,2
+.???.?????# 1,5
+????..????. 1,1
+????#?.?.#??.??#? 2,1,1,1,3
+???.???#???#???#??? 1,4,3,4
+.??##????. 3,2
+?#?#??????.?? 3,1,1,1
+?.?##??.??#?##.? 4,6
+???????.#?#?##???? 4,1,1,6,1
+?..?????.#.?#?? 1,1,1,1,3
+#??#???.?#????? 6,2,1,2
+.????#..??# 1,2,3
+.????????? 5,1
+??????.????# 1,2,1,3
+??.###??????.??#? 1,5,1,1,2
+.????????#?? 1,3,1
+#???#??####?##????? 1,1,8,2
+.??#??????##???#? 3,4,2
+??...#???.##??#????? 2,4,2,4,1
+#?.#??#???. 1,2,1
+#.??##??????##? 1,5,2,3
+????.#.?#.#? 2,1,1,1
+???????????#??????#. 8,8
+#???????#??#.???. 4,1,4,3
+.?#?#?.##??????.? 4,5
+.???#.??...#? 1,1,2,2
+?.??#.?.#? 3,1
+???.?????#???..???? 1,1,7,3
+..?.?#???. 1,2
+??.##?#.?. 1,4
+??.#?#?#??# 5,1
+#????#???#?#?.#??? 2,3,1,2,1,1
+?????#???#??????.? 1,1,9,1,1
+.????????????#? 1,1,1,3
+???????#??#???#?#?? 2,1,4,6
+??.???.????#?? 2,1,1,3
+.??##????#??. 4,1,1
+????#??.?#???. 1,1,2,4
+???##???.?? 5,1
+?????#.??#???##??? 3,1,9
+??.#.???.? 1,1,2
+????.????#??? 1,1,1,3
+?#??#??????.??##..#? 2,1,1,1,3,2
+???.???????#..???#.. 8,1
+??#??????????#???..? 1,1,2,1,5,1
+?.#?##???#?#? 1,4,3,1
+?#.?????##????? 1,7,1
+?.#????#?? 1,1,2
+####?..??###?##????? 4,12
+?.???##????????? 5,5
+??#???##??.??.?###?? 9,1,5
+.??#???#???#????# 4,5,4
+???????#?#??????#.?? 3,10,1
+?????..#?#???. 2,1,4
+?.????.???#?#?? 2,4
+?.##??.#?#? 3,3
+#.?#??????. 1,6
+????##??#.?????#??.? 1,3,1,1,6,1
+??.????#??.??#??. 1,1,4,2,1
+#??.#?##?####?.?? 1,1,10,1
+.??##??#??. 5,1
+???.??.?#????.??? 2,1,5,1
+???.???.?#???###.?? 1,8
+???#??#?.??.#???.. 5,4
+..?#?????? 5,1
+???#?#.????. 4,2,1
+??#?????#?#??..? 3,5
+???#?#??..??? 1,2,3
+?????.???..? 4,3
+?#????????#?.???.#?? 12,1,1,2
+??#???..#??????? 1,1,2,1,5
+#????????.?.?????.#? 1,4,2,1,1,1
+??###?#????..?? 11,1
+?#????#..??.? 2,2,2,1
+???##??#?#??.??.#.# 10,2,1,1
+#??????????.???? 1,5,1,3
+??.???#??????.?? 1,3,3,1
+???.#?..?????###? 1,1,8
+?##????##???#??..#? 9,2,1
+.???#?##???#????#? 12,2
+..#????.?? 2,2,1
+.?#??..#?#??#????#?. 4,1,7,2
+?.?????##?? 2,3
+??????..???????##?## 2,1,1,1,6
+#?##?..?.?#?.??????? 5,2
+?#???#???#? 6,1
+??.#?.?.?#?? 1,1,2,1
+.?#??.??.????.?#?.? 3,1,1,2,2,1
+??#???.?####?##? 1,1,1,9
+??????.?????#.? 2,6
+?.#??#????# 1,1,6
+??#???????????? 1,4
+?#????#..??##??? 6,5
+?#?.?##????? 2,4,2
+#?#?????..????#??? 3,2,6
+?????#?#?.???#??# 1,6,4,1
+??##??.???.. 5,2
+##?#??###?#? 2,6,1
+?#?.??#?##??#???.# 2,1,10,1
+?#.???.###? 1,3
+.?#??.#??????? 4,1,4
+#?#??##?.??#?????? 8,1,2,3
+??#.??????? 1,4,2
+.???#?#??????##?? 1,3,7
+????#?????#?#???..?? 1,12,1
+??##?#????#?#?#?#??# 7,10
+?.????#????#??#?.?#? 1,3,6,3
+..#?.?????. 1,1,1
+#?????#??#?#?# 3,1,2,3
+.##?#??????.?..??#.. 10,3
+??.?##?.?.?.?????#? 1,4,1,2,3
+?.????##?###??????? 1,12
+??#..????.??? 1,1,2
+#??#???#????#??.?#? 2,11,2
+??#?.?##??????##?? 4,5,1,4
+?#??#??#???.??.??.? 1,2,3,1,1,1
+???..#?#???? 1,3
+??.#?##?#?. 1,6
+??##??????????? 4,1,4
+????..?#?. 1,2
+?????.?.#.??##?# 1,1,1,1,4
+.?#?##?##???????? 11,1
+?#.?.?????. 1,2
+##?#?????.? 5,2,1
+?.??????..#?.??#???? 1,4,1,1,1,3
+##??#??#???.?.? 8,1,1
+?????#?????.???#.? 6,3
+?#??.????? 2,2
+???.#?#?#???? 2,1,5,1
+??.?.#?#??? 1,3
+????#?..??????.?. 4,6
+?#?..??????.? 2,1,1,1
+??..###?????.??? 2,6,1,1
+??????????###????.?? 8,4,1,1
+??#?.?.#.????. 4,1,1,3
+????##???#?????##?? 10,3
+.?..#??#?.#????? 1,4,1,2,1
+?#..?#?????#? 2,4,2
+?????.#?#.?##. 2,1,1,3
+???.?#?#.??? 1,1,1,1
+?.#??..?.????. 1,1
+??#?.???#?##?????? 2,9,1
+?#?.???..??#??.???? 3,3,1,3,2
+?##?#?#?????.#??#. 3,6,1,1,1
+????##??.#? 5,1
+.?????.???##??#?.??. 1,1,1,1,6,1
+.???#????.....??#??? 4,2,4
+?.??#???????.??? 2,1
+?.#??#?..#???#?.?? 1,1,2,5,2
+.???##????????##?#? 1,15
+.#?.??.??. 1,1,1
+?????#???.?????#??# 2,4,1,7
+???#??#??#.???#.??. 4,4,4,1
+??.??.#????.??. 1,1,1,2,1
+#?.??.?.???.??? 2,1,1,3,2
+#?.???#??.??????? 1,6,2,1,1
+.??#?.??????## 2,8
+???###...????. 5,3
+??#.??#?####??#?#. 1,13
+.????#???#????? 1,2,2,3
+?????##??.????.?.? 3,5,1,1,1,1
+?..??.??.??.? 1,1,1,1
+.?#??????. 1,2,1
+?#??????????????? 2,3,4,1
+##???.?.#.? 5,1
+??#.????.???????? 2,1,1,7
+?????#.??#??#????# 4,1,6,1,1
+????#?.??? 1,1,1
+??#??.??#?. 3,4
+.?.?.#?.?#?#?#?? 1,1,8
+????.????#??????? 1,10
+??#??????#??#?. 4,8
+????#?????#??#?#? 3,8
+???.???#?????? 1,1,6
+.??.??.???. 1,3
+#??#?.#???##??? 1,2,7,1
+?#?.##?????### 3,2,6
+.#?.?##?.#?? 1,4,1,1
+.???#?##?..?.?#?. 5,1
+?????.???#??#?? 3,6
+??#???##???#????# 3,9,2
+?????#???#?.??????? 1,1,3,2,3,3
+???#?????#?.?#? 3,1,2,3
+.???.???### 3,5
+???...????#?# 1,1,5,1
+????#?#??.??####?? 5,7
+??..??#?????#?##? 1,1,1,1,4
+??????#??? 3,1
+?###??????? 6,2
+##?????##?????#??. 3,4,1,3,1
+???????#??.????####? 1,1,1,1,1,6
+.###.?????? 3,1
+??.#.?????###?##? 1,1,12
+?#??..?????#?#??#? 1,11
+?..??????#. 1,1,2
+??.###???.?.##?.#?#? 1,3,1,1,2,4
+.??#???#??? 3,2
+.?????#?.??? 1,1,1,3
+????.???????###????? 2,1,10,3
+??.??#?###? 1,7
+??#?????.???. 1,5,2
+#?.??..???.??? 2,1,1,3
+..?.????#??#? 1,1,5
+#??#????.#???.# 5,2,1,1,1
+.#.#???#??? 1,1,5
+..?#???#???.?#???#? 9,6
+?#?????.?.?#????##.? 1,2,1,1,2,4
+???#?.?#?#.?#???#..? 4,4,5,1
diff --git a/2023/src/bin/day_12.rs b/2023/src/bin/day_12.rs
index b3a610b..65ffa15 100644
--- a/2023/src/bin/day_12.rs
+++ b/2023/src/bin/day_12.rs
@@ -1,19 +1,127 @@
-use nom::IResult;
+use nom::{
+ branch::alt,
+ character::complete::{char, line_ending, space1, u32},
+ combinator::{map, value},
+ multi::{many1, separated_list1},
+ sequence::separated_pair,
+ IResult,
+};
use std::fs;
fn main() -> Result<(), Box<dyn std::error::Error>> {
- let input = fs::read_to_string("inputs/day_2.txt")?;
- let parsed = Example::parser(&input).unwrap().1;
- dbg!(&parsed);
+ let input = fs::read_to_string("inputs/day_12.txt")?;
+ let parsed = SpringField::parser(&input).unwrap().1;
+ dbg!(&parsed.possibilities_sum());
Ok(())
}
#[derive(Debug)]
-struct Example;
+struct SpringField(Vec<SpringRow>);
-impl Example {
- fn parser(_input: &str) -> IResult<&str, Self> {
- todo!()
+#[derive(Debug)]
+struct SpringRow {
+ springs: Vec<Option<Spring>>,
+ check: Vec<u32>,
+}
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+enum Spring {
+ Good,
+ Bad,
+}
+
+impl SpringField {
+ fn parser(input: &str) -> IResult<&str, Self> {
+ map(separated_list1(line_ending, SpringRow::parser), SpringField)(input)
+ }
+
+ fn possibilities_sum(&self) -> usize {
+ self.0.iter().map(|r| r.possibilities_count()).sum()
+ }
+}
+
+impl SpringRow {
+ fn parser(input: &str) -> IResult<&str, Self> {
+ map(
+ separated_pair(
+ many1(Spring::parser),
+ space1,
+ separated_list1(char(','), u32),
+ ),
+ |(springs, check)| SpringRow { springs, check },
+ )(input)
+ }
+
+ fn fill_in_springs(&self, bits: usize) -> Vec<Spring> {
+ let mut current_bit_index = 0;
+ self.springs
+ .iter()
+ .map(|maybe_spring| {
+ maybe_spring.unwrap_or_else(|| {
+ let current_bit = bits & (1 << current_bit_index) != 0;
+ current_bit_index += 1;
+ if current_bit {
+ Spring::Bad
+ } else {
+ Spring::Good
+ }
+ })
+ })
+ .collect()
+ }
+
+ fn generate_check(springs: Vec<Spring>) -> Vec<u32> {
+ let mut check = Vec::new();
+ let mut current_count = 0;
+ let mut in_bad_lands = false;
+
+ for spring in springs {
+ match spring {
+ Spring::Good => {
+ if in_bad_lands {
+ check.push(current_count);
+ current_count = 0;
+ }
+ in_bad_lands = false;
+ }
+ Spring::Bad => {
+ current_count += 1;
+ in_bad_lands = true;
+ }
+ }
+ }
+
+ if in_bad_lands {
+ check.push(current_count);
+ }
+ check
+ }
+
+ fn possibilities_count(&self) -> usize {
+ let unknown_count = self.springs.iter().filter(|s| s.is_none()).count();
+ assert_ne!(unknown_count, 0);
+ let max_possibilities = 2_usize.pow(unknown_count.try_into().unwrap());
+
+ let mut possibilities = 0;
+ for i in 0..max_possibilities {
+ let springs_guess = self.fill_in_springs(i);
+ let generated_check = SpringRow::generate_check(springs_guess);
+ if self.check == generated_check {
+ possibilities += 1;
+ }
+ }
+
+ possibilities
+ }
+}
+
+impl Spring {
+ fn parser(input: &str) -> IResult<&str, Option<Self>> {
+ alt((
+ value(Some(Spring::Good), char('.')),
+ value(Some(Spring::Bad), char('#')),
+ value(None, char('?')),
+ ))(input)
}
}