From 23b27a2a8a58bd5661d608f44e505c276b431de4 Mon Sep 17 00:00:00 2001 From: Luke Else Date: Tue, 12 Dec 2023 21:02:08 +0000 Subject: [PATCH] Pretty much there with Day 12... just need an eternity to let it run :) --- src/input/day12 | 1000 ++++++++++++++++++++++++++++++++++++++++ src/input/day12_test1 | 6 + src/input/day12_test2 | 6 + src/main.rs | 2 +- src/solutions/day12.rs | 68 ++- 5 files changed, 1073 insertions(+), 9 deletions(-) diff --git a/src/input/day12 b/src/input/day12 index e69de29..d463575 100644 --- a/src/input/day12 +++ b/src/input/day12 @@ -0,0 +1,1000 @@ +..???.??.? 1,1,1 +?#?##???.???? 2,5,1,1 +?#??????##? 1,1,2 +?#.#?#??#??? 1,7,1 +?#???#?#??.#.###.? 3,1,3,1,3,1 +?#......#.?.?. 1,1,1 +.????#????? 2,1,2 +#.?...?#????#??? 1,7,1 +?.#??.??#? 2,1,1 +.#???###?#??#???#?.? 7,1,7 +?###?.??#??..? 5,4 +.#?.??#????#?.?. 2,4,1,1 +#.#??????? 1,1,4 +#????##.???#???. 1,1,2,1,5 +?.?.##???#???##.? 2,7 +????.?#?.? 2,2 +??.#?????#??#. 1,10 +???????.???#?? 6,1,2 +#?.#???.?? 2,4,1 +?####????.?.?? 4,3,2 +?????#???? 6,1 +????.???????#?#.? 1,5 +.#???##.?#??#??? 6,5 +??#?#?????????????. 8,4,1 +???.????#?#.???? 7,4 +?#???#?.?????????? 2,1,8,1 +#?.#?#?.?? 1,3,2 +?.??##??????.?. 1,5,1 +????#????????#????.? 5,9 +?.#?#????? 1,5 +??????#.??.??.? 1,5,1,2 +##?#??????#.#?#??? 5,1,2,6 +????.?##?#..# 2,3,1,1 +??.?..???.?#?#? 2,4 +???##???.?#??#?# 1,5,6 +??.????#?????#?? 1,9 +??##?#????.#???.#??? 1,8,4,1,1 +##?#???????. 4,1,3 +?#???##?????#? 1,1,6,1 +????????##?#?????? 1,14 +????#????.??? 1,2,1,1 +?##.???.#???.#?.??# 3,1,1,4,2,1 +?##???????? 2,2,1 +?????#??????.??# 1,5,1,1 +#?#?????????#.? 5,1,1,2,1 +.?.?.??.#. 1,1,1 +.?#.??#?#?????###?. 2,12 +??.?????#???.???? 1,1,1,4,2 +??????#?##?#?? 2,6 +..????#?##???? 1,4,1 +.?#?#??.#???. 2,1,1,1 +.??????#?? 1,1,1 +?#?.?#???#???#? 1,4,1,2 +??????????#???##?. 1,1,10 +???##????.??? 1,4,1,2 +.???#??.##???????##? 5,3,1,6 +?#??#???.??? 1,1,1 +.??..?????#. 1,4,1 +???#?????.. 1,3,1 +?#???.?#???#?..#??# 2,1,5,1,2 +?#??#?.???.#???. 1,3,1,2 +.#??#?.???#???#?? 1,1,9 +?.?#?##...??? 1,4,1,1 +??#?#?#??##???????. 3,3,3,1,3 +???#?#?.??#? 6,3 +?#?.#??##.#? 1,1,2,2 +?????##??#??? 6,3,1 +????##???? 1,2 +???.???.???.?. 2,2,3 +??#????????????# 5,1,1,3 +????#?.?..????.??# 2,1,1,2,1,1 +.?##?##???? 3,4 +?..??????#? 1,1,5 +..?????#.?.##?#.?? 4,4 +#???.?????? 2,2 +?.??#??????.? 1,4,2 +?###??#???.?#?.?? 3,1,1,2,1 +?????????.????????# 1,1,1,2,4 +??#.??#?##.???.???? 1,1,6,3,1,1 +???#.###????. 3,4,1 +?#.?????????.?# 1,3,3,1 +#.???#.????????#?? 1,1,1,2,7 +???#?.?????.#? 1,1,4,1 +???#..???.? 3,3 +?.????#####??#.?#?? 1,1,9,1,1 +????#.?#???? 2,1,5 +.#?#..#??????????? 3,1,9 +?.??..???? 2,1 +???????#??.???????.? 1,1,4,1,1,2 +..??.??????? 1,1 +??.?????##?? 1,6 +????????##??.????? 1,7,1,1,1 +???.?###???? 1,5 +#.?###??#?#???????? 1,4,1,1,3,1 +????.???????????? 2,1,7 +#?#??#????.?#????? 7,1,1,1 +?##???#.?#???#?##??# 3,1,2,4,1 +???#??#?????.?##? 7,3 +?????????..??? 1,5,1 +.???#???.????#.? 5,1,1,1 +?#?????#????? 2,3,1 +.???#???#???..??##. 5,1,4 +?????.?##.# 5,2,1 +??#????#?.# 5,2,1 +#?.????#???#????? 2,1,2,1,2 +????????.??.?????? 7,5 +..#?#??###.??????? 8,3 +#?.??.??##?.?#? 1,1,5,3 +.#????#?#?##?. 1,8 +?#?????#.? 1,3 +.???.?..#? 1,1,1 +??.??.????? 2,1 +?#??????#??##?##... 1,11 +.#?????????? 1,1,3,1 +??#????#?????#??#?? 8,5 +?#??#???..##.?? 7,2,2 +?.????.#??#?.?##?? 1,1,1,2,5 +.?.????????#??##??? 1,2,5,4 +?.???##?.????#???## 5,3,4 +#..#?##?#?#?????? 1,8,4 +?????##?.?#.?? 1,4,2,1 +?????????. 4,1 +???#??.???????#?. 5,5,1 +?.???.?#????##???# 1,1,8,1,1 +???????..????? 1,3,4 +?#?##??#?????#?#???? 8,6 +???#????#.??????..?. 5,3,6,1 +?.??##???.??#? 6,2 +??.??.???#????#??? 2,1,8 +?????##????.#?. 1,1,7,1 +??.??#??.?.##? 5,3 +???.?#?#??..?? 1,5,1 +.#????##?????? 1,7,1 +.??????..#?. 1,1,1 +#?#??##.?.??. 7,1 +?##?#???..?#.???# 4,1,2,1,1 +???????#?? 3,3 +?.????.#?#??##.??.? 1,1,4,2,1,1 +?.?????##?.? 1,1,5,1 +.#???.?.?##.?.? 1,1,2,1,1 +#.??.?#?#? 1,1,3 +?????.?#??#???# 1,1,8 +.??#?##??.??.# 1,6,1,1 +#??????#??#???#? 1,6,1,2 +.??..?#????#???#??? 2,3,7 +.??#.??##.?#?.#?#? 1,1,4,1,3 +???.??#???.???. 2,1,1,2 +?#?..???#??.? 1,2,3 +?#??#.#????????.?.?? 1,1,6,1,1,2 +#??##?#????.?#???## 1,4,1,1,1,2 +.???#?????? 1,2,1 +??.?.?##..??#?. 1,2,3 +?.#?.#?#??#??#?? 2,3,6 +?#??.#??.???????? 1,1,2,6 +?#??.#???#???#.??.?? 4,1,6,1,1 +##????#?.??????# 4,1,2,1 +..?##????.. 3,3 +.??#?.???? 3,1 +??..????#?.?? 1,2,2,2 +?.????.???.#..#? 2,1,1,1,2 +??#?##?#??##. 6,3 +????????.?????.?.# 1,1,3,1,1,1 +.?#?###?#?????.???? 8,2,3 +.???##??#?.?? 5,3,1 +.?#??##??#.?# 9,1 +?##???.??????? 3,1,1,2 +?#?#?#?????????????? 6,1,1,1,1,1 +.??#??##???#????. 11,1 +?#.#????##?? 2,1,1,4 +?.?.?.??#?????.??# 1,1,8,1,1 +?.??.?????.? 1,1,4,1 +?.#???.##.????.??? 1,2,1,2,3,2 +.?.#??#??? 1,1,1 +?.???????## 6,2 +?.?.#?.##???.?. 1,2,2,1,1 +???..?.??#???#????# 2,1,1,1,3,2 +?????????.??#? 2,1,2 +.?.?#.#??#?????#??? 1,1,4,1,1,1 +????#??.?#????#??? 4,4,2 +.????.?..?.??.?#.?. 1,2 +??#?????#?#??.??#??? 1,1,8,4,1 +?????????? 1,4 +?.?#??.?#?????#? 2,3,4 +???.##.??.??? 1,2,1,1 +.?.???????#.#.. 8,1 +#??.????###??????? 1,1,3,8 +??#?#.#??..?? 3,2 +#..??.????#???.#?#?. 1,1,5,1,1,1 +??.??.???#??.? 2,1,6,1 +.????##???? 1,7 +.?###?.??.? 4,1,1 +?.?#??#?.#..??#??? 6,1,1,1,1 +.??????.?# 4,1 +##????.?????.?? 6,2,1,1 +.?????#.?? 1,3,1 +?.????#??#?????? 6,3,1 +.????#?.#?.?????#?# 6,2,6,1 +.?.???#????###???##? 4,10 +?..?#????? 4,1 +.??#??.?##.?.#?#?#? 3,3,1,1,1,2 +..??#.??????.? 3,1 +??????????#?????.. 1,6,1 +??#????#?????###?? 7,6 +???..#???? 1,1,1 +..#?#??...???#?.? 1,1,1,4,1 +..#..????#???####. 1,10 +?#??????.??? 1,2,1,1 +??????.#???. 5,4 +??#?#.????? 4,1,2 +?#??.??.??#.? 1,1,2,2 +#???.??#??#?.?#??##? 1,1,1,5,7 +???.??#?.?#?? 1,4,1 +.??????#???#????#?. 3,5,6 +???????#?? 2,2 +#??#?#?###?..??#???? 1,4,4,1,3 +?##??????#?##???? 4,2,7 +???????..?.#???? 5,1,1,4 +?????????#???#??? 1,1,1,7,2 +?.##.???????#???. 2,6,1,1 +.?##?#?.?#?..?. 5,3 +.????.?.?. 2,1 +??#??#?.????.??..? 5,2,2,1 +????##?#???. 1,3,1,1 +#?.??##?###.??#? 1,1,6,1,2 +?.?.?#?.#?.? 1,3,1,1 +?????????##???##???. 2,2,3,6 +#????????.???##.? 4,4,5 +???????..???? 5,1,3 +??.????##????###??? 2,1,5,5,1 +??...??#????#???. 2,8,1 +???#??????? 1,3,2 +????.??..?.?? 2,1 +.???.#?????. 1,6 +??#?????#.??.#?? 3,1,1,1,1 +##?.???##????????? 2,4,1,2,1 +???###??##?.?.?.???? 9,2 +???#????.? 1,6 +??#???#?..#.#?? 5,2,1,3 +.??#????????#? 8,1 +?.?#??#????#??? 1,5,1,2 +???..?.????#???#.? 1,1,1,3,1,1 +????##???.#?#?. 4,4 +??#?.#???? 3,2 +?.#??#???#????? 1,6,1,1,1 +??????#?#??#?.???? 1,1,7,1,1 +?.?????.?. 2,1,1 +.??##?.?#???? 2,2 +.#??#??#?????.??#.? 1,5,2,2 +?.??#?.???# 3,1,2 +?..???????? 1,5 +#?????????#?#??.?#. 2,1,2,7,2 +?.?????##.?#??# 1,2,2,2,1 +?????.??##. 2,4 +??##??#??.?#?????. 1,6,6 +???###???? 5,1 +###???#???.????????. 4,1,1,1,2,1 +??.???#.?#?. 2,3,1 +?#?.??#?.?#????#?? 1,2,1,3 +?????????#?? 1,7 +??????????????????.? 1,5,4,4,1 +?#.?.???#?? 1,5 +?###?????#??? 5,2,3 +?.???#???#??????. 1,1,4,2,1 +?????#??####.##??#? 6,4,2,3 +???.#???.???#???? 4,4 +??#?.#?###????? 1,6,2 +??????#?#?#???.????? 2,8,3,1 +.?????.???????????? 1,4,3 +?????.?##???? 4,3 +???#???.??#??? 4,1,4 +#?????.?.#. 3,1,1 +.?##???##?#??????. 2,1,4,1,1,1 +??????#?.????. 6,3 +?.???#?#?#??.#??# 2,1,5,1,1 +???##?##?.?.??#.? 8,3 +???#???????..?? 1,1,1,2,1 +??#???#.??#??..??? 7,1,3,1 +????#?.?.#.?? 5,1,1,1 +#??##.?#????#???? 1,2,1,5,1 +???#.????..?##?? 4,1,2,1 +???#?????.??.????# 5,1,1,1,2 +????.?.??#?????#? 1,1,1,1,8 +???#???#??## 2,5,2 +#.????#?.?#????????? 1,5,1,1,1,1 +##?#?#?.?? 6,1 +.#?#??????#????.?? 1,2,3,2,1 +?#?????.#?? 7,2 +???#????.?. 1,4 +?.#.?.???.##.## 1,1,2,2,2 +???????.?.??#??#.? 2,4 +????.???.#?? 2,2,1,1 +.??#?#?????#?#??#? 5,3,4,2 +##?????????.?????? 6,2,2,2 +???#???????? 1,1,2,1 +???????????..??#? 2,1,1,1,3 +?????.??.???? 5,1,3 +?????????..?# 1,2,2,1 +??????????.?#..?? 3,4,2 +???#?#?????#..????? 9,3 +??????.?#??#???#? 1,4,1,6 +??#?#????.??? 5,1 +???#.?#?????##. 3,9 +?????#???.????#? 2,1,4,1,3 +.??#???..???? 6,3 +?#.?#..??. 1,2,2 +.????????.? 1,2,1 +??.?#??.???? 1,2,1,1 +.?..#?.??.?.??? 1,1,2,1,1 +???#?#????###???? 2,1,3,4,2 +????..??## 1,2,4 +????????..???#????#? 1,3,1,9 +??#????.##?..??? 5,2,2 +???????##.???#?. 3,5,3 +?#???.???????? 4,8 +???????#???..#?.? 4,5,2,1 +???.??##????.#??.? 1,8,1,1,1 +??.?###???.??#.?? 1,6,1,1,1 +???.##??#?#? 3,7 +.??.???????????? 1,6,5 +?#?#?.??.??.??? 5,1,1,1 +?????#????#???#??#. 5,2,5 +??#?#?.??#??#??????# 4,13 +#??#????.???## 8,1,2 +????.????. 2,2 +#??#???#?????#? 4,3,3 +#?????#.#?.? 2,2,1 +#???.??.#.#? 3,1,1,1 +???????#?.?#??## 2,2,5 +???##?.#???????#. 2,3,4,3 +?#??.???.#. 3,2,1 +#?##?.?????.#?#?# 5,2,1,5 +???#????#.?????? 4,1,1,2,1 +#.?.?##?#?#???#? 1,11 +?.??.?#??##?? 1,7 +?????#..#?.##?#????? 1,2,1,4,3 +#????.?##????##??# 1,1,4,5 +?#????.???##? 3,5 +?#?.??????? 3,1,1 +.#.???#...#??. 1,3,3 +?#?...???#? 2,1,1 +??.#??.???..? 1,3,1,1 +.?????.#?? 5,1 +#?????#.##?#?????? 2,4,7,1 +?.????.??#??#??#??.. 3,1,1,6 +??????????? 2,7 +?.????..?#?# 2,4 +?????#..?#????# 1,1,1,3,2 +??.#????###???????#? 9,4 +?#??.##?.??.??????? 2,3,1,2,2 +.#?##.?#??# 1,2,5 +??###?#?#??????.?#? 1,8,2,1,2 +?#.###???#??????? 2,11,1 +?.?.????#??#?# 1,1,1,3 +?????.??#???#? 3,2,2 +?#..???.??##???#?? 2,2,3,1,1 +??#?#..?#???? 3,1 +?????????.? 2,1,1 +??#?#?.?#?. 5,2 +#????#?????#.??. 8,1,1,1 +#???#?#???.##..?#. 8,2,1 +.#.?#?##??.?..??.?#? 1,5,1,1,1,3 +???#????.???.# 5,1,1,1 +?#??..???#. 3,3 +????#?????#..??#? 1,2,5,1,1 +..???????##???? 3,5,1 +??#?##.???#??? 5,3 +??#?????????##?##?? 5,5,2 +.#???????? 7,1 +?.?.#.?#???????? 1,1,1,5,1 +??##...??#?. 3,3 +.??????#??? 2,1,1 +#??.??????.? 3,1,1 +..?..?..?????#? 1,3 +??#.???????#??? 2,1,6,1 +???#??.??. 3,1 +.##???...#????##? 5,7 +??###????.?????? 8,4 +??##??..??.?# 6,1,2 +?????#.??# 1,1,1 +??#?????.?#??????? 4,1,1,4,2 +??##??..??? 6,2 +##?##??#?????#??#.# 11,1,2,1 +.?##?#.?#. 5,1 +?????#??????##? 1,11 +????#????????####? 2,1,6 +.?.?#???????? 6,1 +???#?#????.??#?? 5,1 +#??#.???##?????#? 1,1,6,1,3 +.??.?#???????# 1,4,1,2 +??????#???..??#?#?? 4,5 +?????.?..????##?#. 2,8 +?????.#.?#?? 4,1,3 +?????#???.??.??# 1,1,2,1,3 +?#??????.??#???#??? 1,1,2,4,4 +.???#?#???. 1,1,3 +????.??###??? 1,1,3,1 +.?#????#?##?#.? 2,5,1 +..?.????.?.??#??? 1,3 +???##?????.. 3,1 +##???????????#?? 8,2,1,1 +????###?????##?..? 1,1,6,4,1 +.?????????#??#??#?? 10,2,2 +?#.??????? 1,1,1 +#.????????## 1,1,1,2 +??#?.??????#.?.???? 3,2,1,1,1,1 +?#?.#??#??????.????? 2,7,1,4 +?##??#????##?#?.##?? 2,3,3,2,4 +#..#?.??#??#?? 1,1,6,1 +#.???..???????? 1,1,1,4,3 +?##????.?? 2,1,1 +.?#??..##????..?? 2,6,2 +..#?.##???. 2,4 +#?.???#.?? 1,2,2 +???##??????.??. 1,5,1,1 +?#???#??#.????? 9,1 +????#.???? 5,1,1 +#??????.#???#???# 1,2,1,7,1 +#?????##??#????.???? 3,8,1,1 +?.#????##?#??.?..?? 1,2,8,1,2 +#???????.??#? 1,2,4 +??###??.?.? 6,1 +.??????#.??? 1,1,1,3 +.??#??###???#?..?#.. 9,1,1 +?.?.??##?# 1,6 +????#?????# 1,2,3 +??##??????##??# 11,2 +?#?????#?? 1,2,1 +#.#??.???#.##????#? 1,2,2,1,8 +?#.??#?????? 1,3,1,1 +..???????.? 3,2 +#??.?.???????? 3,1,1,1 +??##???#???# 8,1 +#????.?#??#????#.. 1,1,1,1,3,1 +?####?#???.?.? 8,1 +..#.???#??.. 1,4 +.??.?#??????#???? 1,9,2 +?#?.?????? 3,4 +#??.#?????????? 2,2,3,3 +??#????.???. 5,1,1,1 +.??#???#.??#?. 3,1,3 +.?#??#.#?.?#?.# 2,1,1,2,1 +??????????.?????. 8,2 +?.???.??.?? 1,1 +#?.?????##..###? 1,1,4,4 +?.#??.????.##? 2,3,2 +????#????? 1,2,2 +?###?.#???? 4,2 +.?.?.????.?.#?? 1,1,1,1,3 +.??#???.???#??##???. 4,5 +..??#??#..##?#. 4,2,1 +?##???##??.??????.?? 8,2,2 +#??#?????#?#. 1,5,1,1 +???.?????#??. 1,1,4 +..???##??#??.?? 7,1 +??.#.?????.??????#? 1,1,1,2,1,2 +?#.#?.#????##??##? 2,1,1,1,2,2 +?##?.?..##???? 3,1,4 +????..?#??#.? 3,5 +.#?##???.?#.. 6,1 +?.?.???..#????? 1,1,1,2,1 +?.#???#????#?#?### 1,12 +??.?#?#..?#??.???? 3,3,1 +???#?##?## 1,7 +#???????.#.#..#? 6,1,1,1 +????????.????#?? 2,2,1,1,3 +?????.?#?#?#?????## 2,2,5,1,3 +??????#.???? 1,4,1,1 +?????#??.##?. 1,2,3 +?????#???.???.? 1,6,1 +?#??.??#????#??##? 3,11 +??#?.#??#???? 2,4 +..??#????.??? 2,1,1,1 +??????#?#??..? 2,3,1 +?#?#??.??###????? 4,5,1 +???#??##?#??.?.??#? 1,1,6,1,1,1 +##?.#.?.#??#.#? 3,1,1,2,1 +?##??.?.?????#? 3,2,3 +?##?#???##???#.#?#? 12,1,1,1 +???#?#?.?#???. 4,3 +.????##??. 2,2 +??#???#??#?????????. 1,8,3,1,2 +?#????#... 2,3 +??.??#???? 1,3,1 +?#?.????????#? 1,3,1,1 +?..??#?.#.????? 4,1,1,2 +?????.????#?????.?. 5,7,1,1 +??.?#?.?##???#??#? 2,2,8,1 +?????.#??#??#?????? 1,1,2,1,7 +??.?????.#? 1,4,1 +?#?#???..##?? 5,3 +?.?.??????. 1,2,1 +?#?#.?#?#???????.# 2,1,7,1,1 +??????????????#???? 2,1,1,9 +#?.???.??. 1,1,1 +#?.?????#??.##?#? 1,1,4,5 +?.????#??.? 3,1 +???#??##????##??.?. 1,1,11,1 +??#????????#? 1,4,1,1 +???#...?.? 2,1 +?#????##??#????. 1,1,2,5 +?.?.#???????.#?.??. 4,2 +.???.#?#?????#???#? 1,1,8,3 +?.??.?.?.??# 1,1,1,3 +#?..#?.?#? 2,1,1 +?.????.#??#? 1,1,1,2 +?#???????? 2,2,1 +.?????.???.??????.. 3,1,1 +.?#?.##?##. 1,5 +??#????...?##. 6,2 +??..#??#??????????. 1,14 +#?.#?????##.#???.#.? 1,8,1,1,1,1 +#????##???.????.?? 1,1,6,1,1,1 +????#.???? 5,1 +?##?#???####?#?? 4,1,7 +?.?????.?#??.#? 1,4,2,1 +??#?.?????. 2,1,1 +???.?#???? 1,3 +##?????#?#?.#??#?# 2,1,4,1,1,1 +?#????.#??##.#?? 3,1,5,1 +.?#.?#.#?.?? 2,1,2,2 +??.????.#? 1,2,1 +??..????#.?? 2,1,1 +??.?.?#?#.???? 1,1,3,2 +?#??.????#? 3,6 +?????#????###?? 3,4 +?##??.#????????#??? 4,1,4,1,2,1 +??##?#??????????. 1,11,2 +#?.??????#??#?#??##? 1,15 +#?..???##?.#? 1,1,2,1 +?.?????#??#???.? 1,6,1 +?##??????#?.? 6,2 +..?###??..?.????. 5,4 +???#??..?.#. 3,1,1 +??#??#???###.?#?? 12,2 +?.?#..?#.? 1,2 +##??#?????? 2,1,1 +#?#?.#??#?.?# 4,4,1 +???#??#.?? 1,2,1 +?#?.??.???# 2,1,2 +?#??#??#???.?.?#??? 10,2 +?????.##?#???? 1,2,5,2 +?.?.?#??????##. 1,3,4 +.#??..????#..#.??? 1,2,2,1,1,1 +.?..?#?..????? 3,1 +??????????.??. 7,2 +??.?#?###.??? 1,5,1 +.???#??.??#??. 2,1,5 +?#???????.??#? 2,2,4 +#?#????.???#?? 5,2 +?#??#???????#?.#?? 1,1,4,1,1,1 +#?#??##..?#????#??. 7,1,3 +?##???.#?. 2,2,1 +.??.????#??#???? 1,7,1 +?#?.??##?..??? 2,4,2 +..?#??.??. 2,1 +??????????????.???. 4,2 +#.?#?#????#???#?.?? 1,1,11,1 +??#??.#?..#?#. 1,2,1,3 +.??????#?#?#??. 2,1,1,1,1 +?.???.???##???? 2,1,4 +??.??????.. 3,1 +.?#?????#?#??..? 1,6 +.?#?????????? 3,3 +.??..#??.???? 1,3,2 +??#?###??#??. 2,8 +?.??##???#??#?.?? 1,5,6,1 +????????#?? 2,1,4 +??###?????? 4,2 +?.###?????#???#. 3,2,1,3 +#????#????? 1,4,2 +????...??????#???.?? 1,2,1,1,6,1 +??????#??#?.?.???# 1,1,7,1,3 +??#.??#??? 2,5 +.?##???#????##???#? 4,2,2,2 +?#??#.??.???#?????#? 4,1,1,2,1,2 +??.??????????.? 1,1,1,2,1 +??.????#.????#? 1,1,6 +??#??#?????? 7,2 +???.??????#??????? 3,2,4 +#?#?#?#?????.???? 1,1,8,1,1 +???????#?????##????. 1,9 +??.??.???##??.????.# 2,2,5,2,1 +???#....#? 2,1 +??##?.??????#.. 1,2,1,1,1 +#?????##?#????#?. 5,5,1 +???.#.????.???????? 2,1,1,1,3,1 +#????.#????.????. 1,1,4,4 +?????###???#??.#? 3,4,2,1 +??.??#??????? 2,1,1 +???..#???# 1,1,1 +???????????????? 2,1,1,2,1 +???##?????? 2,1 +??????##????#???? 7,1,1,1 +#?#?..???#?##? 4,5 +#.????#?.????#.?? 1,2,1,5 +.???.?????...?#?.?? 1,2 +?#?.?#????????.???## 2,4,3,5 +.??#.#????#?#????#?? 3,2,9,1 +??####.???#?##?? 5,1,2,4 +??????????#?#?#?? 1,1,1,2,3 +?#?#?????###???##.. 4,2,8 +???#??.?????#?? 1,2,1,4 +?.???##???. 1,3,1 +?#?#????#???#? 1,6,4 +?.?#?.?????#??? 3,4 +???##??#?## 1,2,4 +?#?????????.?? 5,1 +.??##????#?#?????? 2,6,1,1 +?#??#??##. 1,5 +?.????.??#?. 1,1,1,1 +???#???.??#???#??#? 4,10 +#???#?#.????????#? 7,1,1,1 +#????#?#?? 4,3 +???.??.?????? 1,2,3 +??.#.??????##??? 1,1,1,1,6 +??????.???? 4,1 +?.?#??.#??. 3,1 +?.##???#????#??????? 3,1,1,3,2 +.?????#????.??#?.?. 3,1,3,1,1,1 +?#??#??????#? 1,3,5 +???#?.?.?. 5,1,1 +##..??#??##?? 2,8 +?????#????# 2,3 +?#.???###?????.. 1,7 +?###???#??##??# 8,5 +??.?.?#????? 1,1,2,2 +?#?.??.?#? 3,1 +????????.????#?#.?# 1,2,1,6,1 +??##...????.????#?. 3,1,5 +????..???.?..? 3,1,1 +.#???.###?#?? 2,3,2 +?##?#??????.?...# 4,2,1,1,1 +???#?????#.? 1,4 +??.??#??..????. 1,3,1,4 +.##?..??.?#?? 2,1,3 +???##.?.?.?????#?? 1,2,1,3,2 +??#??#?.?????????. 5,2,5 +#??????#.??#?? 1,2,1,3 +.??#???????? 7,2 +.#?#?.??#.? 3,2 +????##?##??..???. 9,2 +.????.???#? 3,4 +?.??#??###?#?#?. 9,2 +???#???.?? 2,1 +.?.??????? 1,2,2 +??????????.#? 1,5,1 +?????#?.???#??.??? 1,4 +??#??.##.?? 3,2,1 +???#???#??#?#????? 3,2,5,1,1 +?#???????.. 4,2 +.?????#????.?#?? 5,3 +?..????##????????? 6,4 +?????#?.?.??.#?? 3,3 +???#???.#?#?.?#??? 1,2,1,1,2,3 +#????.??#??. 4,1,3 +???#??????#???##? 4,9 +??.?..#?.????.. 2,1 +#??#.??.#????#? 1,1,2,7 +???.?#.?..?.?? 2,2,1,2 +?.?#?##??.#.#?.?#. 1,5,1,1,1,2 +?#?#??##???#???? 11,1 +.????..#???##? 2,1,1,2 +#??.??##?.?.??#??#? 3,4,1,3,3 +##??.?#?.###? 2,2,3 +?#???????????### 1,1,1,1,3 +.?#?##???##??????? 4,4,1 +?.????????#????? 2,2,6 +?#??.?..######?# 2,1,8 +???.??.???##..???#? 1,2,1,2,1,2 +...##??.#?.?? 4,1,1 +?.#?..??.? 2,2 +?##??..?##???? 4,2,3 +???#?#??????.?#??? 8,4 +?#.?????##.??#? 1,2,4,2 +???#.#???##?.# 3,2,2,1 +?????????????..?.? 1,6 +#???????.?# 4,2,1 +???????#??? 2,1,3 +.???.######?.? 1,6 +??.??????. 2,1,1 +?#????.????#?#.?.??# 3,7,3 +??#??.????? 3,2 +???#?????????????#?? 10,6 +.?.????.???. 1,2,1,1 +??.????#.?#?? 1,2,1,2 +.?.???..?# 1,1,1 +?#?...?##??? 2,2 +##??##??#?.?.??. 10,1 +??#??????????.?.??? 12,1,1 +?????#?#???#????.?# 1,11,1 +?.???.?.??? 2,3 +??..?#?#??#???#?? 1,2,9 +.#???..??## 3,1,2 +?##?#??.?.????????. 6,1,1,1,1 +??????#?????#??.?? 1,13,1 +#?..????.#???#?? 2,1,6 +.???#??..#? 4,2 +????..?#?? 1,2 +.??#????????.#.?? 8,1,1,1 +#??.??.?#. 2,1,2 +??#.?.??????##?? 1,1,4,3,1 +??.??.?#?.?????#?? 2,1,1,2,3 +?#????????#?.?#. 10,1 +??.????????? 1,5,2 +?????.?.???#???.?.?? 2,6 +.?####?#?#???#??? 8,3,1 +?????##.?#????.??.? 1,4,2,2,1,1 +.?????????#??????#? 3,10 +.??.????## 1,2,2 +?.##.?.??##?.? 2,5 +?????#???? 7,1 +.?#...?.#. 1,1,1 +.???##.???#.?.##?. 5,1,3 +?.?????..?..# 1,2,1,1 +??#??????#?? 4,4 +?????#??.?. 4,1 +???#?.?#?#??.? 2,1,5,1 +??????.????. 1,1,1,2 +.?.???#.#?????#?? 1,3,1,2,3 +????#??????#??.??#? 12,1 +??...?..??????#.?? 1,1,6,1 +.?.??.???.?#?? 1,2,3 +?.????#?????#?##??? 1,13 +?.???#?##???.#..??? 1,1,1,4,1,1 +?.#?##???#??#.?? 1,9,1,1 +??#?.?#??#.? 1,5 +??.#?????..????#???? 1,1,3,8 +???#?#?#???#?.??# 1,10,2 +.????##??? 1,5 +???#??..?.? 6,1,1 +?.?.????????#???? 1,1,3,1,5 +????????#?..?????? 5,2,6 +?????????#????#.?# 2,5,1,2 +.???????#??#?? 2,6 +#??..?##.?? 3,2 +?????????#?#??#?#. 2,5,4 +?#??.?.?#??? 4,1 +###?????##.?.#?#... 10,3 +???#?##?.???#?#????? 2,5,2,1,3 +??#?.??.??#.##???#.. 4,1,1,1,4,1 +??#???.??????.? 3,1,2,1,1 +??#???#.??##????? 1,2,2,7 +.?#??.????##??#?.?? 3,7 +?.???.???? 1,1,3 +?????.???????????### 1,1,1,1,1,5 +?.?.?????#?..??#?#? 1,1,1,1,1,6 +?.#.?.?????#?#?#?#?# 1,14 +?..##???#??#??#????? 1,4,12 +??????#?#?. 6,1 +#??..??###??.??#???. 3,5,4 +??##.?##.??????.? 3,2,1,1 +??#????.??.????? 1,2,1,1,2 +#?#????????.??????? 5,2,5 +???????.????? 2,1,1,1 +????.????###???? 2,6 +#??##?##????.. 9,1 +#??#.##??? 1,1,3 +###?.?##?.? 3,4,1 +??#???##?#?????# 2,11 +.?#.??.??.? 1,2,1 +??????#????.? 2,6 +???##?#???.?#??#? 4,1,4 +....???#?..##?..??? 5,2,2 +?..?..?????.##?###?? 1,1,4,6,1 +#??????????? 2,1,1,4 +??#?????.?????#??.? 5,2,4 +.?????.????? 1,1,3 +?#?.?????#????#?#??? 3,2,1,5 +.?#??????.? 3,1 +#???.??.??.# 4,1,1,1 +?.#?.????????.??? 1,2,2,1,2 +??.?#?##??????.. 5,1 +??####????.?#?.?? 7,2 +.?###??????????## 5,2,1,2 +#??.?????.???#? 2,2,1,2 +????????#??.??#? 1,1,3,3 +.?????????????# 3,7 +###?#?.??? 3,2,1 +?#?##??..#?#?? 5,1,1 +.#?.?#...??# 2,2,3 +.#???#?????#??. 1,1,6 +??##????????? 5,4 +.??##??.????.?? 5,1 +???#?#.#??###?#?.# 1,1,1,1,5,1 +?????#????? 3,1 +.?????.?#.? 1,1,2 +??????..?.?? 1,2,1,1 +????#.???????????.? 1,7 +??#??????##??#. 3,2,5 +???????.???#??.???. 5,1,1,1,1,2 +?#?????#?##.???#??.? 1,5,2,1,4,1 +.???#..???????? 4,1,3 +?????.???. 2,1,1 +??#??.##??.? 2,2,1,1 +.??#???????...??#??? 10,1,1,1 +.##??#???????..????. 5,2,1 +.?#?.?.???#? 2,3 +???????.???#?? 1,2,5 +???.??????.????#??? 3,3 +??????????????#.? 1,1,1,5,1 +???????.#?? 4,2 +#?????#????????.? 1,1,8,1 +###??#????? 6,1 +???????????#?..???# 3,5,3 +??#####??????.?? 6,3,1 +?.????.??.?? 3,1 +.##??#????#..??... 2,7,1 +??#?#?????.#. 4,1,1 +#?????##?#??..???? 2,1,6,1,2 +??###????????? 7,1 +???.??.#?#.?????? 3,2,3,2,2 +?#?????#?????? 2,8 +???????#?#? 1,2,3 +?#?#??.?#.??##???? 4,1,1,1,5 +??????#??# 1,5 +?#?..??#??. 1,4 +???????????. 4,1 +.?##?#????????#??.. 4,8 +???.????...????.. 2,2 +??????.#..??? 1,2,1,1 +?????????? 1,3 +???#?.??????.? 4,1,1,1 +?.???????#. 1,1,2 +??.??????.????#?? 2,1,1,2,5 +.???#??????.#??. 9,2 +?#?#?.??.????. 2,2,2 +.?.?????.? 1,2 +#????#?#???.???.? 1,3,1,3 +..#?##???????#??.??# 6,1,3,1,1,1 +?.?..#?????.???????. 2,5 +?.?.???.???? 1,2 +?.#???.?..?.#?? 1,3,1,1,2 +?.??#???.????? 1,4,1,2 +#??.??.??# 3,2,1 +????#???????#? 5,3 +?#?.?#??.?????? 2,3,4 +##???.??????? 5,1,1,1 +??..?##?????????. 5,1 +.??????.#??#.##...# 4,1,4,2,1 +?.???#???.???. 1,4,2 +##?#???????.?????##? 6,3,1,4 +???.??.#?#? 2,1,3 +???.?.##..?????? 2,1,2,4 +#????#??##??.?#? 2,1,4,2 +#????#?????.???.. 1,1,2,2,2 +???#?.??.????? 1,3,5 +?????##??????????# 1,6,1,1,1 +?#?#???.#???????.. 4,8 +???#??#???..?#?. 2,5,3 +?.???#.?.??????? 2,2 +.?#?#???#???#?#?? 4,9 +.?#?..#?##????.???.. 2,4,1,1,1,1 +???#..?.?? 4,1 +.#??.?#???#??.???? 1,8,2 +.?????#??##?#???? 2,2,2,1,1 +???.?#?.?. 2,2 +?##??#??.??.##??#??. 6,7 +.#.??????#?????#?# 1,1,3,3,5 +.?.?????????????##? 1,3,1,7 +??.??????#?##??? 1,1,3,3,1 +?????.##?#? 1,1,5 +.##.??#?.??.?? 2,2,1,1 +??#..#??#?..#??? 3,5,1,1 +??#????????#?????? 13,2 +?#????..?.??? 2,1,1 +?????#?.#????. 4,2 +.?##?.?..? 4,1 +?##?#??#?##??#?? 12,2 +#?##?.???????#?#?#? 1,2,1,8,2 +?.?.##?.????#??# 1,2,1,1,4 +????.???#?.? 1,1,2 +..????##???????#???? 7,5 +??????#??????? 1,8,2 +?#?????????. 1,1,5 +??#?##???????????.? 8,1,3 +#.??##???###??. 1,10,1 +.????#??#?#???.???# 12,4 +??.?#????#?.???.. 1,7,1,1 +???#####?????.##?? 7,1,3 +?.?????.#?#?.?. 1,5,3,1 +..??..##?????. 2,2,2 +??????????#? 1,1,1,1 +#?#??.??##??#..? 4,2,1 +#?.????.???.? 1,4,3,1 +?????#????##?#?### 1,1,1,1,8 +?.??##??.?#.? 6,1 +#???????.????? 4,1,3,1 +#???#???#??..?#..??? 3,1,1,3,2,1 +#??.???????#????? 3,9 +??#?##????#??????.? 5,8 +#???????#???.?#???#? 1,1,5,2,3 +.#???#????###.??. 1,8,1 +?#???#?##?##???##?#? 2,12,1 +#.?.#???#.? 1,1,2 +?.??#?#.???#?????.?? 3,3 +???#.??.??#??#??? 1,5 +?????#???? 2,3,1 +????.?#??#?????????. 2,1,5,2,4 +.?????.#???##?#.?.? 2,1,6,1,1,1 +?..#?.??...?#? 1,1,1 +?#.??????? 1,1,1 +??###..?#? 4,2 +????##.?#.#???????? 1,2,1,5,2 +#??.?###?##???.?? 1,1,6,1,1 +???#?????...???.??? 4,2 +?.?.??.??#????.? 1,1,5,1 +??#?.?????.?????? 2,1,1,1,4 +?.?.???.?#?#???? 1,1,2,3,1 +??##?..??#??.?.. 2,1,1 +.??.??.???? 1,2,2 +?#.??##????#.???? 1,3,3,2 +??#?#??????#?# 5,7 +??#.??#.#?#???. 2,1,1,6 +??#????.??. 5,1 +????#??.???##?#?#? 6,8 +#???#??#?? 2,1,1 +??.???#???#? 1,5 +.#...??.????.?# 1,2,1,1,1 +##.????#?.#..?#? 2,4,1,2 +????#???#?.?.?#??? 9,1 +?#.???#??#??????#? 1,4,1,1,1,1 +??????.??.?????#..? 2,4 +??.?###?.???#??##??? 4,5 +?#..##???#?#?? 2,10 +..??????#?.?##?. 1,4,3 +?????????? 2,5 +????.?????????#?##?. 1,1,2,2,2,5 +.?????#?.#?????? 1,3,4,2 +??.????#?. 1,4 +?#?#..#.#??##????? 3,1,6,1 +?..?.??.??????? 1,2,6 +.#??#?#?????## 2,3,6 +?#?..???...???##.? 1,3,5,1 +?###??????##?#?..??? 3,3,6,2 +?????#.?#???. 1,2,1,4 +???????.??#???? 1,1,1,5 +.???.??..?#???.?? 2,3 +#.??.#?????..???# 1,1,3,1,4 +?.??.?????????. 1,1,2,6 +?#.#???..?.?#?? 2,1,1,1,2 +????????#??.??#????? 1,1,4,1,6 +.#????#?#.? 3,1,1 +?#??#.????.#?.. 1,1,2,1,1 +?????##??.?????? 2,6,1,2 +#.??.???.???????. 1,2,1,1,4 +??##?#?#??..??? 7,3 +?#???.??.?. 4,2,1 +?????#?????.# 5,1,1 +?#?.??#?.?#? 1,3,3 +?.??.???#?#???. 1,5 +??##.?#???.???.#. 3,4,2,1 +.???..??.??. 3,1,1 +#?..?.??#?.? 2,3,1 +##???#.?#?.#?? 6,1,2 +?#.??.?#.? 2,1,1 +???????????? 1,1,1,1 +?..#???#??#?#?.?# 1,2,3,4,1 +?##?#??????????##. 11,3 +#?#??..?.#?????#???# 1,1,1,1,11 +??.?##?#??.??#???? 1,6,5,1 +??.?#?#..?.?. 4,1 +##?..????.?#.?#? 3,1,2,2,2 +???#.???#? 1,1,2 +??#?????#?#?#???#? 13,1 +??#?...??.#?.?#?? 1,2,1,2 +?.??.????#.????.??. 1,1,1,1,4,1 +??.?????.#? 1,5,1 +??.#?????#.. 1,4,1 +?..#??????.?? 2,1 +??#???#?.#?? 6,2 +???????#?.#?? 3,1,2,3 +?#?#??##.?#???#??? 8,1,5 +??##?????.????? 5,1,1,1 +???..??.?##. 1,1,1,3 +?.?#?..#.?#? 3,1,3 +.???????#??#? 7,1 +.#.????#?#?#?. 1,3,3,2 +??#.#..????????#??#. 3,1,8,1 +#??????#.??? 1,1,1,1 +?#?????#???? 2,1,1,1 +#?????#??#??#.?#??? 1,7,1,1,1 +???#.???.???.?? 3,2,1,2 +??#?.???#####?##?? 1,1,1,10 +??#?????.#??? 6,1,2 +????#????#?.?? 2,4,2 +????????#? 1,1,5 +???#???.?#.?? 4,2,1 +?#??..???#?#??????#? 4,1,5,4 +?#?.?#?#???##?#? 1,4,4,1 +???#.?.#?????# 3,1,1,1 +???.?#?.????? 2,1,5 +.?????#?#??##.?????? 9,3 +??#???#.???? 7,1 +????#?####.?#? 6,2 +?.?????????#??.# 1,1,2,6,1 +?????.?.???#???? 4,1,4,2 +#?.?.??#?#??? 1,1,3,1 +??#?.?????#??? 4,1,5 +?.?????.##..??? 1,2,1 +???###?#??.???.? 7,1 \ No newline at end of file diff --git a/src/input/day12_test1 b/src/input/day12_test1 index e69de29..c5bec3a 100644 --- a/src/input/day12_test1 +++ b/src/input/day12_test1 @@ -0,0 +1,6 @@ +???.### 1,1,3 +.??..??...?##. 1,1,3 +?#?#?#?#?#?#?#? 1,3,1,6 +????.#...#... 4,1,1 +????.######..#####. 1,6,5 +?###???????? 3,2,1 \ No newline at end of file diff --git a/src/input/day12_test2 b/src/input/day12_test2 index e69de29..c5bec3a 100644 --- a/src/input/day12_test2 +++ b/src/input/day12_test2 @@ -0,0 +1,6 @@ +???.### 1,1,3 +.??..??...?##. 1,1,3 +?#?#?#?#?#?#?#? 1,3,1,6 +????.#...#... 4,1,1 +????.######..#####. 1,6,5 +?###???????? 3,2,1 \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 841162c..9eb9c0d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,7 +19,7 @@ async fn main() -> Result<(), Box> { Box::new(day09::Day09 {}), Box::new(day10::Day10 {}), Box::new(day11::Day11 {}), - // Box::new(day12::Day12 {}), + Box::new(day12::Day12 {}), // Box::new(day13::Day13 {}), // Box::new(day14::Day14 {}), // Box::new(day15::Day15 {}), diff --git a/src/solutions/day12.rs b/src/solutions/day12.rs index 5bf7b2a..de630f6 100644 --- a/src/solutions/day12.rs +++ b/src/solutions/day12.rs @@ -5,16 +5,47 @@ pub struct Day12 {} impl Solution for Day12 { fn part1( &self, - _input: &mut Vec, + input: &mut Vec, ) -> Result, Box> { - Ok(Box::new("Ready")) + let mut ans = 0usize; + for s in input { + let springs = s.split_whitespace().nth(0).unwrap().to_owned(); + let nums = s + .split_whitespace() + .nth(1) + .unwrap() + .split(',') + .map(|n| n.parse::().unwrap()) + .collect::>(); + + ans += self.solve(&springs.as_bytes(), None, &nums); + } + Ok(Box::new(ans)) } fn part2( &self, - _input: &mut Vec, + input: &mut Vec, ) -> Result, Box> { - Ok(Box::new("Ready")) + for l in input.iter_mut() { + let (s, n) = l.split_once(" ").unwrap(); + *l = format!("{s}?{s}?{s}?{s}?{s} {n},{n},{n},{n},{n}\n"); + } + + let mut ans = 0usize; + for s in input { + let springs = s.split_whitespace().nth(0).unwrap().to_owned(); + let nums = s + .split_whitespace() + .nth(1) + .unwrap() + .split(',') + .map(|n| n.parse::().unwrap()) + .collect::>(); + + ans += self.solve(&springs.as_bytes(), None, &nums); + } + Ok(Box::new(ans)) } fn get_day(&self) -> u8 { @@ -22,7 +53,28 @@ impl Solution for Day12 { } } -impl Day12 {} +impl Day12 { + /// recursively counts the number of permutations of spring we could get from + /// the splits specified in 'nums' + fn solve(&self, s: &[u8], in_group: Option, cons: &[usize]) -> usize { + if s.is_empty() { + return match in_group { + Some(n) if cons == &[n] => 1, + None if cons.is_empty() => 1, + _ => 0, + }; + } + // Resursively match based on the whether we are in a block and/or we have spaces left to fill + match (s[0], in_group, cons) { + (b'.', None, _) | (b'?', None, []) => self.solve(&s[1..], None, cons), + (b'.' | b'?', Some(n), [e, ..]) if n == *e => self.solve(&s[1..], None, &cons[1..]), + (b'#' | b'?', Some(n), [e, ..]) if n < *e => self.solve(&s[1..], Some(n + 1), cons), + (b'#', None, [_, ..]) => self.solve(&s[1..], Some(1), cons), + (b'?', None, _) => self.solve(&s[1..], None, cons) + self.solve(&s[1..], Some(1), cons), + _ => 0, + } + } +} /// Test from puzzle input #[cfg(test)] @@ -44,7 +96,7 @@ mod test { .unwrap() .to_string(); - assert_eq!(answer, "Ready"); + assert_eq!(answer, "21"); } #[test] @@ -61,6 +113,6 @@ mod test { .unwrap() .to_string(); - assert_eq!(answer, "Ready"); + assert_eq!(answer, "525152"); } -} \ No newline at end of file +}