diff --git a/2023/day12/input.txt b/2023/day12/input.txt new file mode 100644 index 0000000..8c3b114 --- /dev/null +++ b/2023/day12/input.txt @@ -0,0 +1,1000 @@ +#??????#??. 2,7 +???#.????#?? 1,1,1,1 +.?????#??#?? 1,2,1 +#.??#?#????? 1,2,1,1 +..????##?????.????? 6,2,1 +#?##???#?#.??.?#?# 1,8,2,1,1 +??????##??#??#??? 12,1 +??..???#?? 1,2,2 +??##..????.?#.?. 3,1,1,1,1 +?###????#??..???.? 5,1,1,3 +#??.???.?#?#?#???# 1,3,3,1,1,1 +??#????#???.?..??. 5,3,1,1 +?.??#??#.????# 1,2,1,5 +##??????#.?#??##?? 3,1,6,1 +#???.????? 1,1,2 +?????#?#??.?.?? 1,2,5,1 +..??##?????..#?? 9,2 +???????.??.#????? 2,2 +##?.?????#?#???? 2,9 +.?#??.??.???. 4,2 +.?#??##..?# 1,3,1 +???.??..?##?. 1,1,2 +???.???##.? 1,1,3 +??#?#?#???##?????? 3,11,1 +??...??#?#. 2,2,1 +?.#?????.??##??#??# 1,5,10 +?????.#.?????##??? 2,1,1,2,1,5 +.?#?.???#???. 1,6 +???##????#??#?????.? 2,3,6,1,1 +?????????? 1,1,1 +??.????.#?#???#?? 1,2,4,3 +?????#???#? 1,5,1 +?????????#?????.?##? 2,10,3 +????????????. 3,2 +????.???#??????? 2,6 +??#?#?###????.????. 11,2 +.??#??#.?#?##??.?? 1,1,1,6,1 +???#?#?.??? 5,1 +?.??###?##?..#?. 7,2 +..????????.?? 3,1 +#?????.?????#???. 1,4,6 +#.?????.?.?.???? 1,3,2,1 +??????#???????????? 1,1,1,5,1,1 +#??###?#.?#???#? 1,5,2,2 +?.?.##?????.???#? 1,1,7,4 +?#?#?#????????. 6,1,1 +?.???#???.??. 1,3,2 +?.??#?##?.?#?????.?. 1,5,3,2,1 +?##????#.# 3,2,1 +???????#????? 2,1,7 +?##?..?.??#? 3,1,4 +.???#???????#?????. 1,1,3,3,1,1 +?#?????#??.????? 9,1 +?#.#??#.????? 1,4,1,1 +???.????.???#?#..?. 2,3 +????##???#???? 1,9 +????.???#.?#?? 1,4,1,1 +.#?????????????.??# 8,1,1,1,1 +??#??#?#??##???#?? 7,2,1 +??#.?.???????? 1,1,3,2 +???#???.??#??#?? 5,1,1 +???#?????????##? 1,1,11 +????#?.##???#?????#? 5,2,4,1,2 +?#??..?.#?????##.??? 4,1,1,1,2,2 +??#??..?##?.? 2,3 +?#???.????.?? 1,1,4,1 +??????#????#?# 4,8 +??????#???? 1,6 +?????.???##??.#??. 1,1,2,2,1,2 +???#?#..??#. 2,3,3 +.#??#?????#?.. 1,8 +?#.###??.??##??? 1,3,5,1 +?????#?.#?? 5,1 +?????#????.?#?? 4,2 +.#?.#??#?? 1,1,1 +????#????.??## 1,2,1,2 +????.??.##.????? 1,1,2,4 +?#.??#?#??? 1,4 +###????????????#?#.? 8,2,6 +#????.??????.#?##? 5,1,2,5 +#?.?.???#??? 1,1,2 +..##?#.??#? 4,2 +?.?#??.??#?. 3,4 +?.?..?.#.. 1,1,1 +.??????..?#???????.? 2,8 +??.??##.???#.. 2,4,1,1 +??.#??#??. 1,1,4 +????????#??#?##?? 2,9 +???#????#..????????? 5,1,4 +.????.?##.??##?#?#. 4,3,6,1 +?#?#..?????.??#??#? 3,1,1,5 +.#????##??.??.??. 9,1 +????.??.?? 1,1,1 +?#????.??? 2,1,2 +.?#?##?.????????.??? 6,2,1,1,1,2 +??#????.???. 5,1 +.????#??#..?##?.?? 6,3 +#?????#?????????#.? 1,13 +?????#.?#????###???. 2,1,5,6 +?#??????.?. 2,4 +???#?#???..#?? 7,2 +??#.????.??##??? 2,2,1,2,1 +??#?.?.#?#?? 3,3 +?????????#?? 3,1,3 +#??#???#???#.?? 1,1,1,5,1 +.??.??????????? 1,3,2,1,1 +.?#???????.#?? 4,3,1 +??#??#?????.????#?#? 3,3,3,3,1,1 +#??????????##???#? 1,1,1,1,9 +?.???..#??? 1,1,4 +??#?.#?#?.?? 1,3,1 +.???????#??? 4,4 +???#????#??.#? 8,1 +.???##????#??????.?? 5,2,4 +???.????#?????#??#. 1,3,1,1,3,1 +???????????.? 1,2,3 +???????##???.? 1,6 +.??????????. 1,1,1,1 +#??#???#??###???#. 1,15 +??#??.#?#???? 3,3,2 +.??##?#????.??? 6,2,1 +.??.?#?#??#??????. 5,7 +?##.???#?#?#?###? 2,11 +?????.??????. 1,1,2,2 +..????...?.??? 1,1 +??####?#.???? 6,2 +.?..?##???.???????? 3,3 +???#????#??????#??? 11,2,1 +.???#??#?..?. 4,1,1 +?????##??##???? 3,2,2,1,1 +?#?.#?.?####? 2,1,6 +???#??.#?#??#????#?# 1,1,1,1,1,9 +??..#?#?#?##..??#? 1,1,3,2,3 +?????????? 1,5,1 +????.?#???#?#?? 2,6,1 +??#.???... 1,1 +.??#?????.??#??? 6,1 +?.???????.?#? 1,2 +???????.?#??? 6,2 +???#?#?.?? 2,2,1 +??.?#.?##????????#?? 1,1,4,3,3 +????.???????.?..? 1,1,4,1,1 +?.?#??.??#???? 1,1,3,1 +####??.??#? 4,1 +???#???####?. 2,6 +????????#.?##?.??. 1,5,3,2 +.??#.#??.???? 3,2 +?####??#??#?.#.?? 5,1,2,1,1 +?#??#?????.#???? 4,1,1,1,2 +.??..????#.??#? 1,3,3 +???#.##?##?????? 2,1,6,1 +?????????? 1,1,1 +#??#?#?.????#?#? 1,4,5,1 +##?.?#???#.????? 2,5,1 +.????.#?##??#???..?. 2,8,1 +?????#????#.????? 10,4 +?????#??.????#? 1,4,2,1 +#??#?#??.??#? 7,3 +??.#?????.#????? 1,3,1,3,1 +??#?????#????. 3,2,1,1 +?.?#??.??.?.????? 3,2 +??#?#?#???#??.????#? 11,5 +?#?????#?#??..?.? 2,2,3,1 +???.#??#?.? 1,2 +?#?#???.??#?? 5,1,1,2 +?#?????.?.?? 1,1,1,1 +?????#??.?? 4,1 +??.????#..#??#?#?.? 2,1,1,1,4,1 +??#????.?? 1,1,1 +#?.???????#.???? 2,2,1,2,1 +?.??.?????.? 1,1,1,1 +?????.??#????.?? 1,2,4,1,2 +?..?#??.#?? 1,3,3 +??????#?#?? 1,4 +??#.?.#??????#??..?? 1,1,1,2,4,1 +.????##???#??. 8,2 +????##..?..??.? 2,1 +?.???..#?. 3,1 +???????#??#??? 2,2,2 +???????.#?????? 1,3,2,1,1 +?#?#.??#???.# 3,2,1 +?#???.?#???#?#????#? 2,1,3,3,5 +?#????.??? 3,1,1 +??#?##?.????#?.? 4,1,3,1 +?.???.????. 2,3 +#?????#?#??#??. 4,7 +????????#??#??? 1,1,1,3,4 +#??.???#???#?#????? 3,4,5,1,1 +???????.?#?.#?. 6,2,2 +????#????? 1,4 +?.???????#? 2,3 +??.??????.?#?#? 5,4 +.?????#??.#??#..###. 1,2,2,2,1,3 +???.???.?##?????? 2,3,8 +#.?.???????.?## 1,1,3,1,3 +##.#??.?.?? 2,3,1 +?.???.??#?#. 1,4 +????#???.?. 6,1 +..??.##?.?? 1,2,1 +?#?##??????#?? 2,3,2,1 +?####?..??#?.?#?? 6,4,1 +?#????.#.?#???#? 4,1,1,2,2 +.??#????????#?#? 4,8 +????#?.???##? 1,3,6 +????.??????#???##? 1,2,4,2,3 +???#??.?????.??# 1,2,3,2 +.???#?##?#.????? 2,4,2,1 +?#???#?..??????. 2,2,3,1 +??????..#?.?##?#?.?? 5,1,4,1 +??????????????#?# 3,11 +?.#??????????#.? 4,7 +??????#?..#???# 1,4,5 +???.?#??###?#??.?#. 9,2 +?.???##????##?#?#? 10,1,1 +??#??????##????? 7,3,1,1 +????????.??. 2,1,1 +.???#???##? 2,2,4 +??#.#.????#????. 3,1,2,6 +???#..?.#? 1,1,1 +?#???####??#.???.?#. 9,1,1,1,2 +.???.#?.???? 1,1,1,1 +?.??#??#??.?#.?? 7,1,1 +.????????#? 5,2 +????#?.?.#? 3,1,2 +???#????.?????#??? 1,3,3,4 +?#.?#??#??##?????? 1,3,5,1,1 +??#?#??.#?? 4,1,1 +???#?????.##.???# 5,2,2,1,2 +?.?#???????????#?#?. 6,8 +?.??#?.?????.???# 3,2,1,1 +?#????????.?? 5,2 +??#..#?.??. 2,2 +?#???#????????#?#? 2,2,1,1,4 +.??#???.????..??. 5,1 +#???.#???? 4,2,1 +?????.##??.?# 2,4,1 +?#??###??? 3,5 +?#??#?#??.. 4,1 +?????????????.?????? 8,1,4 +#?#????????? 4,1,3 +?.??#??###? 1,1,4 +..#????????..##..?.? 1,3,1,2,1 +??#???#???## 4,6 +?.##??.?????#??.# 3,1,1,1 +?#..???????.# 2,1,3,1 +###??????#? 4,1,3 +??.#?#?#????#?????? 10,1 +?????#???????.. 6,2,1 +?#.?#?..#?#??. 1,1,5 +???#??#?#?????.. 3,9 +?.#??..?.???.?? 1,1,1,2,1 +??##???.??? 6,2 +??.?##?#??. 1,6 +?.????#?.#? 2,3,1 +?.#????.????#. 5,1 +?.????.##. 1,3,2 +?##?#?#???#??? 7,2 +?#?????#?.?#? 2,3,2 +#?#???#??#??????? 10,1,1,1 +?.?#??.?#???#??.?#?# 1,2,7,4 +???.#..???# 1,3 +#???????????? 7,1,1 +##?.????..? 3,3 +??.??####???..#? 4,1 +??##???##??#. 9,2 +?##?????#?#?#?##? 3,5,2 +?#?.???????.???????# 3,6,1,1,1,1 +???#?#??.?? 7,1 +??.#?#?#????.# 2,7,1 +????#?#?#? 1,6 +??#?###?????###? 9,1,3 +.????#?##.? 7,1 +?.?????#.????####?. 2,1,1,2,5 +#??.#?##??? 2,6 +.?.#??.??#??? 1,3 +?.#???#?.??#????? 6,4 +?.#?#.?#????#???? 3,1,2,3,1 +#.#?????#???? 1,7 +??#????##?.#.#? 4,5,1,1 +???????#?##????#???? 3,9,1,3 +?#??.?##?????#???##? 1,5,9 +?...???????#???.. 1,5 +??.#??.??? 1,1 +.??#?.?.###?? 3,3 +?.??.??????. 1,4 +?.??????????? 1,6 +#.##?#?#???#???# 1,4,1,4,1 +??.#??.????# 1,2,2,2 +..#???#??????.?.??? 9,1 +.????#?????.?.?? 8,2 +.?#.?????.??? 2,1,2,2 +?#.????..??? 2,1,1,1 +.??????????#?????#? 2,1,2,2,2 +?????????????#. 1,2,1,1,1 +?#?#??????#?.#?###? 12,5 +.?.?????????# 1,3,1,1 +?..##???????. 2,4 +#.??#???????? 1,4,1,2 +###????...??? 7,1 +??.....##?#??#? 1,8 +????????.?#?.#. 1,1,2,1,1 +..???????#?? 4,2 +??#?.?#??#??? 3,2,2 +.#???.?..??. 1,1,1,1 +??.?##?????.?.?#? 2,7,2 +??#??#???#??????##? 1,1,1,3,5 +??.???#??? 2,1 +??#??????.#. 2,2,1 +..#??#???.#??# 6,4 +?#.?#????###??????? 2,1,2,5,3 +?#??#??#???.#..?? 1,4,1,1 +???##??.??#??#??. 5,1,4 +?.#??#?##?.?###? 1,1,6,4 +.#.??#???#? 1,2,4 +??..????..#??? 4,1 +##????#???#??#??#??? 17,1 +?????#?#?.??.??? 2,6,1,1 +???#?..??? 2,2 +.?#??????##???.. 2,6 +??..?.??????#??? 1,1,1,4 +??#?.?##??##??#?? 1,4,7 +???.?????#???.????? 2,1,3,2,2,1 +.?#??????.?.?? 4,1,1,1 +?.??????.??? 3,1 +??###???..?????.? 8,1,2 +?.?#?????. 1,2 +?####??#?##.?.? 10,1 +#?##?.##?#????.#?# 4,2,5,1,1 +?....?.?????? 1,1,1,3 +#.?#???#???#??#??? 1,10,4 +?.????.??#?? 1,4 +??????#?#?? 1,1,3 +.?.?.#??.??#??#? 1,1,6 +#???#???????#?.????? 1,10,1,1,1 +???#??..??#?#.?.. 4,4 +??#????.##?#??????.? 4,1,5,1,1 +?.?????#???#??#?##?# 1,1,1,1,9 +????#?#?#??????? 1,1,1,3,1 +????.#??#.#?????? 1,1,4,2,3 +.#.???.??#??? 1,1,2,1 +?##??##?#??.? 7,1,1 +.???.??????????#?.? 1,1,6,3 +???????#???#.#???.? 1,1,5,1,1,1 +.???#?##??.????##?. 8,7 +??.??????? 1,1 +??#.?#??.???? 1,3 +????#???????.??.#?? 1,8,1,1,3 +.#???????#??##??? 6,6 +?##?#????? 2,4 +???#??#?.?#??##.# 6,3,2,1 +..?#??#???? 4,1 +??#?.?.#??#.###?? 1,1,1,1,4 +?####????###?###???. 4,9 +??#?#.???? 4,1 +?###??.??.?.???????? 4,2,1,6 +##????..?#? 2,1,2 +.?#???.#?#?#? 4,6 +??#???#.????.?.?.? 1,2,2,1,1,1 +??#?????#??????.? 4,3,1,1 +????.?#???##.???#? 1,1,6,1,1 +?#??#???#??? 4,3 +?#?????.?#?????## 2,1,9 +?.???????##?#??????? 1,1,1,7,2,1 +??.????#?? 1,1,1 +?????...?..???#?.. 3,3 +??.???????#???#???? 1,2,12 +???#?#..????#??#. 5,1,2,1 +#?.?..#??? 1,1,2 +.#??#????.#??..???#. 8,1,2,1 +.????#?.????????. 4,5 +?.??###?#?????????#? 10,1 +??#.????#?.. 1,1,1,1 +??????#.??#??. 7,3 +?.#??#???#?.#????# 1,6,6 +?????#?#??#?. 1,6,3 +#?..????##? 1,1,3 +???????##?#### 1,10 +?..#?.?##?#?#? 1,1,6 +?????..#??? 2,2 +??.???.#?. 1,1,2 +????#??##??????#??? 1,6,1,2,1 +#????#?#?????.?? 1,4,3,1 +???????#?#???..???? 1,8,1,1,2 +?????##?????? 1,1,8 +.??..????????# 1,1,6 +??.#???##??#.#?? 2,6,1,1,1 +.?##?????? 3,2 +.?..?..???? 1,1,1 +.???????????#?###?.? 1,8 +?????????##???#??#?? 1,1,12 +???????.?.??.#? 1,2,1,1,1 +???.??#??#???? 1,6,1 +?????#.##????#??#??? 4,1,4,2,2,1 +?#???.??#??#.?. 3,6 +?.?#?#???# 5,1 +#..?#???#??????.#? 1,3,3,1,2,2 +#??????????.?##? 1,6,3 +????????##?#?.#?.?? 1,1,1,5,1,1 +.??##?????##??#..?#? 12,2 +??##?????##?#?? 2,7 +.?#?#????####? 5,5 +?#??#?????????? 1,6,2 +??#????#..?#??##? 3,1,1,7 +????.#???.?###?# 2,4,5 +????#?.??# 1,2,1 +#?#?#??#????..#???? 1,4,1,1,4 +##?#???#???..??? 5,1,1,1 +??#?.????#?#?. 1,1,4 +.#????#?????#. 1,5,1,1 +?..?.???#?????. 1,1,4,2 +.?????.???? 2,1 +##?#????.??? 4,2,1,1 +???##????..?#? 9,1 +#???#?##???#??? 1,1,1,6,1 +?.????##?#.# 3,2,1,1 +??.?#?#?.?..???#.?? 2,4,1,1,1 +.?.???#???##????#? 1,1,9,1 +??.??#?###??? 2,1,6 +?.?.?#??..???????? 2,5 +.???.??????#? 2,5 +??.?##???# 1,3,1 +??.?.#??.??#. 1,3,1,1 +?#??.???.?. 3,1 +#???.?##?#.? 3,3,1,1 +##??????#?#????? 3,1,7 +??.??????????. 4,1,1 +?.##??#??#??.?#??? 1,2,1,4,1,2 +?????#??#?#?. 1,2,7 +?#??.???????. 2,1,4,2 +.?#??.?.#?.??? 3,1,1,3 +.?##?..#?#??#?????. 3,7,3 +?##?..???.. 4,1 +#???#..???.??? 2,1,2,1 +???#?#??..#?... 5,1 +????##???? 6,2 +#.?#???.????#?# 1,3,4,1 +????.#??.?##???.??#? 1,2,5,1,2 +??#??#???? 3,1,1 +??##?????#??? 5,3 +?.#???##?.???.#? 7,2,1 +#??.##?????.? 1,3,1,1 +?#????#?.??? 1,1,1,2 +..?.???????.? 1,4,2,1 +???#?.??.??. 2,1,1 +#???#??.#????.?# 1,2,1,4,2 +.??.#???.????#?#? 1,4,7 +.#???#?##????#?#??#? 1,11,2,1 +??????##?#??????? 1,8,1 +.??..???.?#?# 2,2,4 +????????.#?# 3,1,1,1 +###???????#?..???? 11,2 +?.?.????.??#??? 1,1,1,1,4 +????#??#?#.?? 1,6,1,1 +?#?.?.?#?#?.?? 3,5 +??.#??#??#???????. 1,2,7,1,1 +???.#???#??.? 2,3,1,1 +?#?#?#???. 1,3,1 +??.???.?##??##?. 1,8 +?#?#????.??? 3,1,1,2 +??#?.???#??#.?.?. 2,6,1 +?..#.#?#???????###? 1,1,1,1,9 +?????..???.. 5,2 +.?###..?#?#?????#? 4,6,2 +????###?????? 7,1 +##...?????.? 2,2,1 +.#??####???.? 8,1,1 +?????.#?????#? 2,8 +?..??????????# 2,3,2 +.??#??.???##???#???? 5,5,1,3 +#??.??????##?????? 1,1,1,1,6,1 +????.?###??#?.??? 1,8,1 +..??#?#?..#???#?. 6,6 +?#???##?????.???..? 8,3 +?#?????#.???????###? 7,1,7 +????#?.???#????? 1,2,1,3,3 +?###?????###??#???? 11,1,1 +???.??#??.?.??? 1,1,4,2 +..??#.#.?? 2,1,1 +.??.??????. 1,2,1 +.?..???.?? 1,1,1 +??#??????# 4,4 +?????#.?.??. 1,2,1 +?#?#?.####.???? 4,4,2 +.#??????#??? 3,4 +.?.???.????# 1,1,1,1 +?????#??#? 1,1,2 +.???.?.?##?.? 2,4,1 +??.???##???? 2,8 +??.????..?#? 1,1,2,2 +??.????##???.#??.? 1,1,5,1,2,1 +.#?..?#??? 1,3 +?????#?##???#??.?.?? 7,3 +?.??.?????#???.?.?? 2,1,3,1,1,2 +?.????#??.????.#?#? 1,1,2,3,1,1 +?#???..#??#??# 4,4,1 +???????.???? 5,1 +#??##??#???? 8,1 +##????#???##??? 7,3 +#?#??????????????? 1,1,3,1,1,1 +#???????.??.. 1,3,1,1 +??.#?#??#???#?. 1,11 +??.?#?##??.?#??#??? 1,6,8 +?.?#????????? 1,1,3,2 +???##??????# 1,4,1,1 +?#?###?#.??? 5,1,1 +??????#?#?? 1,4,1 +??#..?.???#??.#?.? 3,1,4,1,1 +???##?.?????? 5,4 +.#.#???.??..????#.? 1,4,1,1,1,1 +#??.#?.??.#.? 3,1,1,1 +??..?..???##..????? 3,3 +?.?.?#??##???...#? 1,1,9,1 +?#??##??#??#?##?? 2,6,5 +#?????.???.? 5,2 +???.?#?##?.???.? 1,6,1,1,1 +?.#??#?##??.?? 9,1 +?.?#?.?...##? 2,3 +?#??##?#???#?? 1,9,1 +.???.#??.?? 2,2,1 +??.??????#???? 1,4 +.?#????.#.?#???#? 2,1,1,1,6 +.?#??????# 1,1,3 +#..????.?.???.?#?? 1,4,1,3,3 +?.??##.????#????### 3,12 +#?????#??#.?? 8,1 +.#?##?#???###.?? 1,4,4 +??#..##??#? 1,5 +????#?????#.????# 2,7,1,1 +?.##????????#? 4,1,1,1 +?#?.?????????. 3,1,4,1 +?.??#?????#????? 1,2,6 +??#?????#.?????# 2,1,1,1,5 +???##?#????? 1,4,1,1 +#.????.????#?? 1,2,6 +??.??.?.?????.?. 2,1 +?.?#.?#????#???###? 2,1,1,8 +?#?#???##?..#??#??? 10,1,2,1 +??#...?.?. 1,1 +?#???#???.?? 1,5 +##?.?#??..??#?## 3,3,4 +????????#?#?? 9,1 +?????#???.??#? 7,1 +?.??????##.??###? 6,5 +?????#??##????# 1,1,1,5,1 +?##???#??###?#???.?. 2,9,1 +?#??..?????#???.#. 4,1,1,1,1,1 +???#...#?? 3,1 +?#????.?#? 3,2 +??##??????#??.??? 3,2,4,1 +#??#???#?###??#.??. 1,12,1 +.?###???????????# 4,1,1,1,1 +##??#?????#??#.??. 3,2,1,3,1,2 +???#??##???#?????? 7,1,1,1 +??????????? 5,2 +??#????#?#????? 9,1 +?????????#????????? 6,1,1,1,1 +?#???#.????##?#?# 2,2,3,6 +.????.???# 1,1,1 +.?##???#..? 4,1 +?????##?.??#.?#???# 8,1,1,1,1,1 +...###???#?#??#????. 9,6 +.#??.?.????#???? 3,4 +??????#?..??#??? 3,3,1,2 +?.?##.????# 3,2 +.???#??###??.?#. 1,1,3,2 +????#?????.#?? 1,2,1,3 +?????.???#? 2,2,4 +??#?#?#???##???.?? 13,2 +#.#.#????#?#?##?###? 1,1,1,1,10 +?????.??.?.?#?. 1,2,1,1,1 +.??#???.??????#? 5,2,3 +..??#???.???#??. 2,2,5 +???#?#??????????#??? 12,2 +..??#???????#??#?#? 1,3,8 +?????????#???#?? 1,1,1,1,6 +??????.??.?#? 2,1,2 +?.???##??##?#?#??? 1,1,11,1 +.?.???????#?#. 1,4,3 +.#???#?.??. 5,1 +.?#?????????#??. 2,11 +?????##???..?. 1,7,1 +??????????##??????? 2,12 +?.??..#?#????#????? 2,5,2 +??###??#???? 3,1,1 +##???#??##?#.?#???.# 6,3,1,1,1,1 +????#?#??#????#?.#?# 1,5,7,1,1 +????#??????#?.???.? 11,3 +#.??????.?#?.?#? 1,1,1,2,2 +..?.?#?#??? 4,1 +??.???????????#? 1,1,4,5 +???#???#?#??. 1,1,5 +?.#???##??.#??# 1,6,1,1,1 +#?????.??#???#??##?# 6,3,7 +.???????.?????? 6,1 +????#?##.#??..?#??# 6,3,2,2 +.?.#??#?.????# 1,2,2,1 +?#????.?#???.?? 6,2 +?????????.????#?? 1,1,4,5,1 +#?#???#????.? 4,2,1,1 +.??#.????#?????#? 1,1,3,1,3 +??.?#????###???# 1,2,5,1 +??????.?????????.??? 1,2 +????????.#?????? 3,3,2,1,1 +???..?#?#?#???? 1,8 +.?#??.????. 2,2 +..???????????..# 5,1 +#??.???????.??#?.?? 1,1,1,4,1,2 +??.?#.??.#..?. 1,1 +??????#??#???#?.??? 3,9,1 +#?#??##??????? 1,1,7,1 +.#?????###??????? 1,6,3 +##?????##?.#.???.# 4,4,1,1,1 +??????.????.?#?# 1,1,1,1,4 +#???????#.#?.? 5,1,2,1 +???.?##?#? 3,1 +???.#???##?#?#?#?.. 1,2,9 +.?????.#?????? 1,7 +?.?#???##??#????.# 1,11,1,1 +??##???#??#..?.. 1,3,3,1,1 +#.????#?.??#?? 1,1,2,5 +??.???..?#???.? 2,1,1,2,1 +?.#..??#?#?#.? 1,1,7 +?#?#####??#??.#??? 13,1,1 +.??.?#?#??????? 2,3,4 +?#??#???#?? 4,4 +?#??#????...????.?? 7,3 +.?.????????#?? 1,5,1 +?##?????#??? 5,2 +#????..?.?.?##???? 1,1,1,1,6 +?#####?#???????. 8,1,1 +?????????? 2,1 +#????.???.?? 4,2,2 +???.??#???? 2,2,2 +???.??.??.???? 1,2,1,3 +?#??????????.??? 2,1,3,1,1 +???.???????#..# 1,1,3,1,1 +??..??????#??###.?# 1,3,7,1 +?#???????.?? 4,1,1 +#?????..????????..? 2,1,5,1,1 +#????##?###?#??.??? 4,10,1 +?.??##?..#???.?? 1,3,1,1,2 +?????##?.??.#.??? 1,5,1,1,2 +?#???????????? 2,4,1,2 +???????#?.????????# 1,2,4,1,6 +?##.???#?????. 2,5,1 +#????#???#??????.?? 6,8,2 +##?##??.#?.??# 7,1,1,1 +???.?###?????#? 2,7,2 +#.????????? 1,5,2 +???#?.?#?????####??? 1,1,2,1,8 +??.????#?.????#?.? 2,4,3,1 +#??.???#???#?.??? 3,8,1 +??.???#??# 2,3,2 +????#.?.???##?? 2,1,1,1,3 +?.?.?.??.?.. 1,1,1,1 +???..?#?#?. 1,1,5 +#??.???#?###?????? 3,1,10 +?..?.?#???#??????? 1,1,4,1,2,1 +?.??##????#?? 3,3 +..??????..?#????? 2,6 +?????#??#?.???? 8,3 +...??#?.?? 1,1,1 +?#.????.#.#. 1,1,1,1 +????.?#?.???????#?? 1,1,2,4,4 +??#??#?#?.?.?.??#??. 8,2 +?#???##??##???#?? 1,11 +?#?###?.#?#????# 1,4,1,1,1 +??##????#????.?#??#. 8,3,1 +??.??#?..#???.. 2,2 +???#?.???.????? 3,1 +#???##?#?. 1,7 +#???.#????# 2,3,1 +?#???#?#?#?????##??? 1,1,7,3,1 +?#??#.??.??# 2,2,1,2 +??#??.???.???? 1,3,3,2 +?..#?????.?? 1,1 +???.???????????#?# 2,5,6,1 +.??????#??? 1,2,1 +??????????#????#? 1,1,2,6 +#??.??..????#.#??? 3,1,1,2,1,1 +?#?????????? 1,6 +##.????.?????##.? 2,1,1,1,5 +##??.??#?????#??.? 3,4,5 +.???..?#?? 1,3 +##??.???????#. 3,4,3 +?..??#???.? 3,1 +?#?#??????????. 8,1 +#???.?.#?#.? 1,2,3,1 +??????#.?? 1,3,2 +?.??...???#?????#?. 1,4,5 +##.?.?????????.#?.? 2,1,8,2,1 +?#??#???.??? 6,1,1 +??#?.?.?.# 2,1,1 +?.?#????#.????????#? 1,6,8 +?#????????.??? 6,1,2 +?.???.#?.????.??## 1,1,1,2,3,4 +#??.#???????????? 1,1,10 +?#?????##?#??????? 1,3,6,2,1 +?.?#???#??###.#??.#. 1,1,3,3,2,1 +????????????.??.? 1,1,4,1,1 +?#??#????.#?#. 1,5,1,1 +##?#??.#?.????????.. 5,1,2,4 +?..?????#..?#??.. 1,2,2,3 +.#?#.?##?????.#??? 1,1,7,1,1 +.#???.???#?.? 3,1,1,1 +?##??????????# 2,1,3,1 +?##??#??????? 5,2 +?#???.##?#?? 3,1,2,1 +???.?#???##?? 1,1,1,4 +???????#?.#???? 1,6,1,1,1 +???.#????#??. 1,8 +#??????#??? 1,5,2 +?#???#.??? 1,2,1 +????#??.## 1,1,2 +?.#.?#???#??.?#???#? 1,3,1,1,6 +?#??#??#..???#?? 2,1,1,1,4 +.#??????#?. 1,1,2 +????##??.??#. 7,2 +.?????#?.???#?? 4,1,1,1,1 +?????..#?. 2,1,2 +..??#???.?????#?.? 2,6 +???#??.??##? 3,3 +.#?.?????????.? 2,1,1,1 +??#??#??#.? 2,1,2 +#..???.???#??.?#?.? 1,1,4,1,1,1 +???#???.##?##?? 4,1,2,4 +????#####??##???? 8,2,1,1 +.#????#?.????? 1,1,3,5 +.??.????.????? 1,2 +?..?#.#????#???#.? 1,10 +???????###.#? 1,1,3,2 +??..?##?#??.?.? 6,1 +.???#???????.??#?#?? 4,1,1,1,5,1 +?#??.????.. 1,3 +??#?.?##.???.?##?? 2,2,3,3 +???#??#??#????.##? 1,1,1,3,1,3 +.#??.?.??#?#.#?#.# 1,1,4,3,1 +?#???.?.??? 2,1,1 +#..#??????#???.?#??? 1,8,3 +??#????##.?..?? 1,5,1,1 +.##?#????.?.???# 6,1,1,2,1 +??###???#???????.?? 11,1,1 +?#???##???#.??#????? 1,7,2,1,1 +#???#??.??.????? 5,1,1,4 +??#?.?##?#?#?#??#? 1,13 +??.#???#??? 1,1,4 +##???#??##????? 6,4,2 +?##?#?????. 5,1 +.????#?.??#????#??? 1,1,1,7,1 +?.#??#?#??#???.##?. 1,2,5,2 +?.???##??. 1,1,4 +?.?#??##?#??##?.? 1,11,1 +??#??.?#???? 3,2 +.???????.?##? 2,2,4 +?????##??.?????.??# 9,1,2,1,1 +??#???##?.???? 7,2 +???#?#??#??.?? 1,1,5,2 +???????#?#?? 2,4,3 +.???..##?? 1,2 +???..????..???#?? 1,4,1,1,1 +?????..????? 3,5 +???#?#???#???#???? 1,7,5 +????#?...??.?? 2,2 +???????#????????#? 2,2,7 +??##.??????? 2,2,2 +.#???#.????#???.?? 5,1,2,1,2 +??????.?.??? 4,1,1,1 +???.???????##?# 2,1,1,6 +##.?.??????????? 2,10 +???.#??#.? 1,1,1 +?#??#?#?.? 2,3 +???.#??#?#?##???#? 9,3 +?????.?????.# 2,2,1 +????..#???.? 1,4 +?????##????##????#?? 6,1,9 +??.#?#???????.??# 4,3,2 +?????.?#?#???.?????? 1,1,7,1,1,1 +????#??##.?????.? 6,2,1,1 +??##?...#?? 3,1,1 +??#???##?.????#??? 3,2,6 +#??#??????.?.??#?? 8,1,1,2 +.?.??#????????.#???? 6,5 +#????#??#? 1,7 +?.#????###????? 1,1,10 +??????????#?.? 4,4 +?.??#?..?.???.?.. 1,2 +.????..?## 3,2 +?#?..#..?? 2,1,1 +??????##?##.??????. 2,5,2,1,1,1 +???.?.??#?##? 3,7 +..?##?###?#?#?.??## 6,4,4 +??##????#??#???.? 5,6,1 +.?..???.??.?..? 1,1 +?????.?????? 3,4 +?.#?.??.??? 1,1 +###.??.#?? 3,1,1 +????...?????##.??. 2,4,2 +??#..???..???##?. 2,1,2 +?????????????##???? 1,6,4,1 +?.???????? 2,1 +?.??..#????? 1,4,1 +?#.?????##. 2,6 +#??##???#?????#? 1,3,4,4 +.?#???#?##????.?.? 13,1,1 +?#????#????##?#??#?# 1,9,3 +.??.???#??#. 1,1,1,1 +?????.?#?#?#??# 1,1,1,1,4 +.???.??##??#??.?? 2,9 +?.??##?.???#?? 5,3 +???#?##????#.???. 9,1 +.???????.#.#?.????# 1,1,1,1,1,5 +#??#??.??? 4,1,1 +?????.??.####??#??.? 1,1,1,1,9,1 +?..??.#???#?#????#? 1,1,1,7,2 +???#???.#.?????? 1,1,1,1,6 +?##??????.??.??? 2,4,1,2 +.?#??.???#??. 2,4 +???????#?# 1,1,4 +???..?.????? 2,1,1,1 +.?????.???? 2,1,2 +?.?????#??. 1,2,4 +.#????#??????? 7,1,2 +#?#???.?.??.?.????# 4,1,2,1,4 +?.#??????????. 4,3 +?#????.#??? 3,1,2 +???#???.???#? 3,4 +.????????? 2,6 +.??#???.???.#???? 5,3,1,2 +#?#??????. 3,3 +#.????#????? 1,1,5 +?.#???.??????#???# 1,1,1,5,1,3 +??????#?????.???. 5,3 +???..?.???? 1,1 +?.??.##??? 1,3 +#?.???#.?.#????? 2,3,1,3,2 +?????##??#??#??#??. 3,2,2,2,2 +..#??.?????.???. 3,1,1,1,1 +?#?#.?#??#?#?????#?# 4,8,5 +???#?.???????#? 1,1,3,2 +????####???#??#?? 1,14 +?.#???##??##.?????## 10,4 +???#?#???#??#???. 7,1,3,1 +???..?#??#??#??? 1,9 +???.?#???#? 1,1,6 +?##??????????#?????? 3,12,1 +?????#.#??? 4,3 +#???#??.????#???# 1,5,1,3,1 +??.?##?#?#???? 1,10 +#.??.???????#??? 1,2,5 +.#????.?#??##? 2,7 +???#?#???????? 7,1 +???#?????#?#? 1,2,4,1 +??#.?#.??????????. 1,1,1,1,8 +?.?.????????# 1,3,1 +?#?#?.??????##????? 1,1,10,1 +?##???.????.?#? 3,1,1,2 +.?????#..???#?#?#?# 6,10 +?###?#????? 6,1,1 +???#.????.?# 1,1,1,1 +?????.??????# 1,1,6 +.#??????###??#?.?? 4,1,3,2,1 +?#??.?.?#..?? 2,2,2 +??????#??? 2,2 +??#?#?????.? 5,1 +???.?##?.??#?#?? 3,4 +?.??.???#??? 1,2 +.????..??.? 2,1 +?#?#??.#????#???.. 5,7 +????????#?#????? 12,2 +?.??.??##??#??##??? 1,2,3,8 +....?#??.?#.???#???? 2,2,2 +????.???????#.?# 2,8,2 +?#????#.?#????#?? 3,3,4,1,1 +???????#????..#? 2,2,1,1,2 +#?.???#??#?? 1,8 +.????#??#? 1,1,5 +???#???..????? 6,1,1 +??????????? 2,4,1 +?.??#???#?????? 1,1,3,2 +#??????????..?. 1,1,2,2,1 +##..????#?.?.??# 2,2,1,1,1 +#??#.?#?##??#?. 4,8 +.?.#?#?#.?????? 1,3,1,1,3 +...?#??#.???.??? 5,3,2 +??#.?##??#.? 3,2,2,1 +???##??#????????#?# 1,6,1,1,1,1 +????????????? 2,4,1,1 +?.????..#?????#???? 1,1,1,3,6 +???.???.?#?#?##.#?? 1,1,6,2 +.?.??.??#.??. 2,1 +#.??..???? 1,1 +.??.?#???##?##??? 2,1,7,2 +#?###?????.?. 7,2,1 +?##?.?.????????.? 3,3,2,1 +???????#??????? 1,1,6,1 +??#??#???#???? 1,2,8 +##??#???.???? 5,1,1 +...#?????..??##??..? 6,3 +#?.??????#??#???# 2,1,5,1,1 +???????#?##?? 1,1,6,1 +#???????#?????##???? 2,11 +?.????#??.??????#?.# 1,1,5,1,4,1 +?.#????#?#?????.?? 11,1 +????#?###?#?#?????? 13,3 +??#??#?????. 4,5 +???????#??#?.???.? 1,4,2 +??#?#?#.???#?.?#?? 3,1,2,3 +??.##.????#????. 1,2,1,2,1 +??#???#????#.?.? 5,1,1,1,1 +?????#??##?#.?? 11,1 +?.?##????????.? 1,8,1,1 +??..???###?.???.##. 2,6,1,2 +??#???##??.??? 10,1 +?.?#???#??.??#? 6,3 +??#?###?#?..?.?????. 7,2,1,2,1 +????##?##?#???? 1,10,1 +#?..??????. 2,1,1 +.??#?.##?????? 3,4 +?#?.????##??.?? 2,7 +??#???.#??#???. 4,6 +?????.#.#?##???.??# 4,1,1,3,3 +?..?#.?###?#?? 1,2,8 +.????#????#????#.?.. 11,3 +.?#???.?????????#? 3,1,6 +??##?#?#???.??#? 9,2 +.?###?##.?#.?.?#???? 6,1,1,3,1 +?.#??????.? 2,3 +??#?????.?.??. 4,2,1,1 +??##??..#?????????# 1,2,1,1,7,1 +???##??????#? 7,1 +???#???#.???#.???? 3,1,1,1,1,3 +?.?????##..?#?#????# 1,1,2,7,1 +???####??##?#??#??? 1,4,5,1,1 +????#?#??##????.# 11,1 +??#??????##?... 4,5 +?#???????#?#???#..? 1,1,8,1 +#??#??.?????#?#? 2,1,1,7 +.???????...?.#??#? 1,3,1,1,3 +?###?#???.?? 8,1 +?#?##?#???#????#?.## 8,4,2,2 +??#?..?#???####????? 2,10,1 +.???#?##??#??#???? 10,3 +???????????.??? 4,5,2 +?#??????#???.? 2,5 +#??..#????????#?.?? 3,1,4,4 +.???#??#???##??????# 1,16 +???.?#???##??##????? 2,2,10 +.#.??????.##???#??? 1,1,1,8 +??????#?????? 6,1 +??.?#?##?#???#?#? 2,7,2,1 +#???.??????? 1,1,1,3 +???????.???????? 2,1,1 +???#???.??.??? 1,3,2,1 +???.??????.???.? 2,5,1 +??.??.????.?##?????? 1,1,2,1,7 +.?#?#??#?.??#? 7,3 +.#?##??##?.#?#?? 1,6,3 +?#????#??????.????? 7,2,2 +???#??.?#?#?? 4,1,2 +?????###???.. 1,8 +???##??#.????.?? 5,1,1,1,1 +?..???????? 1,3,2 +????.?##??????#??#? 1,1,4,6 +???#?##??.??????#?. 1,1,4,5,1 +.?#?##.?.???? 4,1,1 +??.?.??#.? 1,1,1 +?????.#??.???##?##?# 3,2,10 +????#???.? 5,1,1 +??????????.???#.?. 1,1,4,1,1,1 +??????#.#?????#? 1,1,2,5,2 +?#???#????#??#? 1,1,2,6 +?#.???????#????.??? 1,2,1,3,1,1 +?????.?.#??.???#.? 1,1 +?#?#?#????.#???#?. 1,1,1,2,1,3 +??.??#?##???. 1,5 +??#???????.??..## 5,4,2,2 +?..?.??.#?#????#???. 1,2,8,1 +..#??????#????? 2,2,1,3 +..?????#???##??.#? 1,9,2 +?.?###??..? 4,1 +?###.????????#####?? 3,12 +???##??#.#?#? 8,1,1 +?#?#??????.???? 4,1,1,3 +?..?.?????.? 1,3 +????#???.?? 3,1 +????#?#?.#??? 1,5,3 +?.?#?????. 3,1 +#???##???.?.???? 7,1,1,1 +#..#?????. 1,1,2 +??#????.#?????? 3,1,1,2 +?.???????#??##???? 1,9 +???.??#?????#?## 2,11 +?.?#...#?...?? 2,2,1 +???????????.??? 10,2 +...?#.???.??. 2,1,1 +.??.?#?????.? 2,6 +.???##??.????? 5,1,2,1 +#..?????#???#???#? 1,3,6,2 +..????##??????????? 14,2 +?.??..#?##?# 1,6 diff --git a/2023/day12/run.py b/2023/day12/run.py new file mode 100755 index 0000000..73c45e7 --- /dev/null +++ b/2023/day12/run.py @@ -0,0 +1,148 @@ +#! /usr/bin/env python3.12 + +def load_data(filename): + with open(filename, 'r') as f: + for line in f: + line = line.rstrip('\n') + c = line.split(' ') + yield c[0], tuple(map(int, c[1].split(','))) + +# Part One + +from functools import lru_cache + +def match_string(pattern, test_string): + assert len(pattern) == len(test_string) + for a, b in zip(pattern, test_string): + if a == '?': + continue + if a != b: + return False + return True + +def constant_sum_iterator(n, s, t): + if n == 1: + yield (s,) + else: + for i in range(0 if n == t else 1, s+1): + for r in constant_sum_iterator(n-1, s-i, t): + yield (i,) + r + +@lru_cache +def arrangements(pattern, groups): + spaces = len(pattern) - sum(groups) + if len(groups) == 0: + return int('#' not in pattern) + if spaces < len(groups) - 1: + return 0 + good = 0 + for s in constant_sum_iterator(len(groups)+1, spaces, len(groups)+1): + assert sum(s) == spaces + assert all( s[i] > 0 for i in range(1, len(groups)) ) + assert sum( groups + s ) == len(pattern) + test_string = pattern + for i, num in enumerate(groups): + assert len(test_string) > 0 + if not match_string(test_string[:s[i]], '.' * s[i]): + break + test_string = test_string[s[i]:] + if not match_string(test_string[:num], '#' * num): + break + test_string = test_string[num:] + else: + if match_string(test_string, '.' * s[-1]): + good += 1 + return good + +total = sum( arrangements(pattern, groups) for pattern, groups in load_data('input.txt') ) + +print(total) + +# Part Two + +def subarrangements(patterns, groups): + if len(patterns) == 0: + yield int(len(groups) == 0) + else: + pattern = patterns[0] + for i in range(len(groups)+1): + a = arrangements(pattern, groups[:i]) + if a != 0: + for rest in subarrangements(patterns[1:], groups[i:]): + yield a * rest + +def median(s, split_ch): + median_ch = sorted([ (abs(i-len(s)/2), i) for i, ch in enumerate(s) if ch == split_ch ])[0][1] + return median_ch + +from math import factorial +import multiprocessing as mp + +def complex_arrangements(pattern, groups): + if '.' in pattern: + subpatterns = tuple([ p for p in pattern.split('.') if p != '' ]) + a = sum(subarrangements(subpatterns, groups)) + else: + min_spaces = len(groups) - 1 + spaces = len(pattern) - sum(groups) - min_spaces + buckets = len(groups) + 1 + if spaces < 0: + return 0 + combinations = int(factorial(spaces + buckets - 1) / ( factorial(buckets - 1) * factorial(spaces) )) + if '#' in pattern: + if '#' not in pattern[1:-1]: + a = arrangements(pattern, groups) + else: + a = 0 + median_ch = median(pattern, '#') + for i in range(len(groups)): + g = groups[i] + for j in range(g): + a1 = complex_arrangements(pattern[:median_ch+1], groups[:i] + (j+1,)) + a2 = complex_arrangements(pattern[median_ch:], (g-j,) + groups[i+1:]) + a += a1 * a2 + else: + a = combinations + return a + +def worker_task(input_queue, output_queue): + while True: + task = input_queue.get() + if task is None: + break + result = complex_arrangements(*task) + output_queue.put(result) + +total = 0 + +num_workers = 16 + +input_queue = mp.Queue() +output_queue = mp.Queue() + +workers = [] +for _ in range(num_workers): + worker = mp.Process(target=worker_task, args=(input_queue, output_queue)) + worker.start() + workers.append(worker) + +tasks_enqueued = 0 + +for pattern, groups in load_data('input.txt'): + pattern = '?'.join([pattern] * 5) + groups = groups * 5 + input_queue.put( (pattern, groups) ) + tasks_enqueued += 1 + +while tasks_enqueued > 0: + result = output_queue.get() + total += result + tasks_enqueued -= 1 + +for _ in range(num_workers): + input_queue.put(None) + +for worker in workers: + worker.join() + +print(total)