From ea9a19d034fa88ded4f043908396e01bcd5ca0a5 Mon Sep 17 00:00:00 2001 From: Brian Buller Date: Tue, 12 Dec 2023 07:51:40 -0600 Subject: [PATCH] 2023 Day 12 Complete! --- 2023/day12/input | 1000 ++++++++++++++++++++++++++++++++++++++++++ 2023/day12/main.go | 109 +++++ 2023/day12/problem | 222 ++++++++++ 2023/day12/testinput | 6 + 4 files changed, 1337 insertions(+) create mode 100644 2023/day12/input create mode 100644 2023/day12/main.go create mode 100644 2023/day12/problem create mode 100644 2023/day12/testinput diff --git a/2023/day12/input b/2023/day12/input new file mode 100644 index 0000000..491665c --- /dev/null +++ b/2023/day12/input @@ -0,0 +1,1000 @@ +..?????#??.?##? 1,1,2,3 +###?.#???.?#.# 4,2,2,1 +?????##???#? 7,1 +??????#.?#####?? 1,1,1,6 +????#?#.??#?# 3,3,3 +?????#?#.? 2,2,1 +..???.??#??? 3,3,1 +????.??????##??#?#? 2,2,9 +??.#??##??.#?? 2,5,1,1 +.???????????#? 5,1,1 +???.????#??? 2,6,1 +?#???.??#?##??#?.# 2,8,1 +?????.???? 2,2 +????#?#??.?#?.? 1,1,5,1,1 +..?#??#???#?????. 5,6 +??.#..??#??????#???? 2,1,10 +????.????#.??.#??? 1,1,5,1,1,1 +?????????#?##?.. 1,6 +.??.??.??#????? 1,4 +?????.??#????#? 1,8 +?.???????##????#?.?? 14,2 +?#.????#.????.? 1,2,1,1,1 +?#??.???????? 1,1,7 +.????.??????.# 3,3,1,1 +???#??#?.?...? 5,1,1 +.???#???.##??? 2,2 +???#???..?#?? 6,1 +#??.???.#? 3,1,1 +??#???.###???#?.?? 4,3,2,1 +?.?.?????????. 1,1,1,2 +.?.??..???????? 2,5 +?#?#???????.?.?.? 5,4,1,1,1 +??#?#????##??.???? 5,6,2 +???.#?###????.? 1,6,1,1 +.???.??.#?#??? 2,4 +##?#?????#?.#?# 5,2,3 +.##????#?#??#?#??. 3,9,1 +???????#???.??#??? 7,4 +?????..?#??#?#??###? 1,1,1,5,1,5 +.????.??????.##???. 3,2,1,5 +????.#????#?.# 3,7,1 +.???????.?# 5,1 +.???.?#??.???##??#?? 1,1,1,10 +??#??????? 1,3 +##.???.????#? 2,1,1,4 +.?#..??.????? 1,2,3 +??????????#?.?? 5,4 +?#?????????.?## 7,1,2 +??#?#?#????????.?#?. 14,2 +????.??????..??# 2,1,2,3 +???.?#?#????????..?. 1,1,8,3,1 +.??.?#?.?#? 3,2 +??????????.?? 1,2,1,1 +?????????. 3,1,1 +#?.?#?#?.###??#??. 2,2,1,7 +??.??#???? 1,4,2 +???#?????????#?? 4,1,1,3,1 +??..?#?.??.??.#??#?? 2,1,5 +??..???#??.?? 1,4,1 +.??#?.???.????#??. 3,2,7 +#.??????????#?? 1,3,1,2,3 +?..????????# 1,1,1,1 +????????#? 1,1,2 +????##??#????#..# 12,1,1 +?#?##???.??## 1,2,1,4 +.###???..??.? 6,1 +.?#??#?#??.?????.#. 8,3,1 +?#????#???????.. 7,1,3 +??.##???.?. 1,5 +?.??##???.?? 7,1 +#????.#????? 3,1,1,1 +#????????????.??. 7,2,2 +?#???..?#??#?? 4,2,2 +??##??.?.#?#. 6,1,1,1 +#.?.???.???#??#???. 1,1,2,1,7 +????#?????????. 1,4,1,2 +??#??????????.????. 5,3,3 +??.??#####?#???.?? 2,11,1 +??#.????.?. 3,1,1 +.???.##????.. 2,6 +?????#?????#??. 2,3,5 +??????.?.?#???#. 2,2,1,2,3 +??????#??? 1,1,1 +???????????###?#?? 7,9 +????#?##??????? 2,8 +??#??#.#???????#?? 3,1,7,1,1 +????????#??##.? 1,1,6,1 +.????????.? 3,1 +##.??#?????# 2,1,3,1 +???????????#?????? 1,1,10,1 +?????.#??..?????? 2,2,6 +?.###?.???????? 1,4,1,1,2 +.?##?????????. 6,3 +?#??.#??#????#??#? 1,1,1,10 +.????#???? 3,2 +???.#?#???? 2,7 +??#???#?#?#?.?.? 1,5,1,1 +#????.?#??????#?#? 1,2,1,9 +??###????##?#? 5,5 +??##??#??????????? 5,8 +.????.??????? 3,1,2 +??##???????.##?#? 4,3,4 +#?#?????###??##????. 1,2,13 +??#.????#??. 1,1,1,1 +.?#?##?.?#..?? 6,1,1 +#?##??.?.???????#??. 4,1,9 +???#?#?.???#??? 2,2,1,2 +..#????.????#. 2,1,1 +.???.???#?????.? 2,1,3,1,1 +?#????.???.???## 2,1,2,4 +#?#?#???#?##??#?. 1,3,3,2,1 +??#??#???..? 1,1,2,1 +???..##.#?????.. 2,4 +#???#?.?#?#?#????? 5,1,1,1,1,1 +???.??.???? 1,2,2 +????##?.#???.??????? 5,2,1,2,1 +.#???.?.??????#?#?.? 2,1,2,3,2 +??.????????? 1,1,1,1 +???##???????#??????. 9,2,3 +?#?#??#????..?#.. 9,1 +??#.???????#?#???# 1,4,1,1,2,1 +?#?.??###?##????.?? 2,8 +???#????#?#?.? 2,3 +.??##???..?? 3,1,1 +##.#?#.??#?????. 2,1,1,6,1 +?##???.#??? 4,3 +.?##?#?????##???. 3,1,6 +.????#??#???.?# 1,7,1,1 +?????????#.?.?#?. 2,1,2,2 +??..?.##?#??##? 1,8 +??????#??? 2,3 +???#???.#??.#??# 5,1,1,1 +?#?#???.?#.?????#?# 3,1,1,1,1,3 +?????????? 1,3 +?#??##??????????.?? 9,4,1 +??#????????.? 3,1,1,1 +??#.?#??#?#.??.?#.? 3,5,1,2,1,1 +??##??????.?#?#????? 3,6 +???.?#?#???.??. 1,1,3,1,2 +????.???.??????#?#?? 4,1,1,8 +????##?.????#??.?? 1,4,5,1,1 +???#???#?#?..??. 10,1 +###???##?#?#####?# 4,12 +.?.??.???# 1,1,3 +??#?#?.??.? 5,1,1 +?#??###???#???.????? 13,5 +.????#?#????#??# 5,4,1 +.???#???.??#??#.?. 6,5 +.?????..?????????# 4,7,1 +????????????# 1,3,3 +???..?##??###????? 3,2,4,2 +???#???????#?? 1,1,1,3 +?????.?.#####... 1,1,1,5 +????.?##????# 4,3,1,1 +?#???#?#????#???. 1,11,1 +.??.????#?? 1,5 +???#.?.#?#??#?##?# 1,1,1,6,2,1 +?.?.#??#???? 1,1,7 +??????##?#?## 1,7,2 +????????#?..??? 1,1,3,1 +.?.????????.?.? 4,1,1,1,1 +#?.???.??##?.?# 1,3,3,1 +#?.???????? 2,3,1 +???.??.??#???## 1,2,3,3 +????????????#. 3,3,1,1 +.#??..##??.??#?????? 1,1,4,1,3,1 +??#.??.?#???#?? 1,1,7 +???#?#??.?????#?? 7,1,1,2 +...?????#? 1,2 +.?#???#.#???? 5,2 +?#???#???.?#???.? 7,1,1,2 +????#?????#? 1,3,2,2 +?..#???.?##. 2,1,2 +?.?#.??#?? 1,1,1 +?.##??##?##????#?? 1,12,1 +?????#?#..? 1,6,1 +?##?????.??? 3,2,2 +.?.???????. 4,1 +????#???###???? 1,3,4,2 +???.#???.??? 2,1,1,2 +??????##.#.???? 2,2,1,2 +??.????#.??#???????? 1,1,1,7,1 +.??#?#?##.?#? 1,1,2,2 +.?#.???#?#??. 1,6 +..??##?#????.##?. 10,2 +..??#??.?.??.???? 3,1,1,2,1 +..????#?...?.?#??.. 1,3 +..??##..?.#????. 4,1,2,1 +?.????##??? 1,6 +?.???????#?? 3,2 +????.??????? 1,1,3 +???????.?#?##?.??#?. 4,5,4 +?.?#?...?##??. 1,2,3 +?#?#.??#??? 4,2,2 +???##..??????? 3,1,1 +?###??????? 7,1 +?.#????###?????? 1,1,5,1,1 +##?????????????.# 5,1,2,1,1 +.???????.?????.#??#? 2,2,1,5,5 +.?#??#????.???? 2,5,1 +????.??#?#????? 1,9 +.?#???.???? 3,4 +?#???#??.???? 6,1 +#????????##.??. 1,2,2,3,1 +????????#???## 1,3,4,2 +??###?????#??????.. 3,6,2 +???????#?.#??##? 5,1,3 +??.??..?.??#.? 1,1,1 +??##??????.??#???? 1,2,4,1,5 +?????#?.#??###?.??? 1,1,2,1,4,3 +??#??.#??????#. 3,5,2 +??.??????. 1,1,4 +??.????#?????.. 1,9 +?..??..??? 1,1,2 +?.?.?????##?#??#???? 1,12 +????????.? 1,2 +??#??.?#?##.? 1,1,1,2 +.???###?????? 6,1 +.???????????# 2,2,5 +.??????#?#??.?#? 1,1,4,2 +???#??.??. 1,3,1 +.#??#?????..#???# 8,5 +??#?.?.??#??. 1,2,1,2 +??.????##???? 1,1,4,1 +.???#.?.???????? 2,1,5,1 +???????????????#??#? 3,11,2 +???##????????.??? 10,2 +?##??#???#??????? 10,3,1 +.?###????#???.??. 11,1 +???????.?#?????#???? 6,9 +?#??#??.???????# 7,1,1,1,1 +?##??.#?????????? 4,1,5,1 +.????..#??##??#??..? 3,10 +??????????#???#? 2,8,1 +???.??.?#?? 2,1,4 +?#???#??#???#?# 2,4,2,1 +?.#??.#..??#. 3,1,2 +??.???#???.???.?.?? 1,1,4,1,1,2 +????????????.??#. 6,1 +?#??#?#??#??#?????? 2,3,1,8 +?.?????????#??? 6,2,1 +????.?#?#??#??? 1,8 +.?.???.???#. 1,1,4 +.?#?..????? 2,3 +.??#???????? 5,1 +???????????. 1,1,1,1 +.##?....#? 3,1 +???.#?#????? 2,3,2 +#??#..??.?.???? 4,1,1,1 +??##.#??.#?. 2,2,1 +?????????? 2,1,2 +.?.###???##?#???? 1,3,8 +?.?????.#???## 1,1,1,3 +?.???#??#?##??????? 11,2 +.#??.???.???? 3,1,1 +??.?##??.?????.???? 1,4,4,1,2 +???#????.?#? 1,3,1,3 +.???#????##?????. 8,2 +????#.?.???? 2,2,1,1 +??##??..???????##.?. 5,9 +.??????#?? 2,2 +???#??#??#??#.. 1,8,1 +???#????.#.???. 1,4,1,1 +???.????.??#???#?#?? 2,1,9 +?????????..?? 1,1,1,2 +????#.#???..? 4,1,1,1 +#?.??#?##??#???.?#. 2,9,1,1 +?##??.#??.? 2,2 +?#?.??##?? 2,4 +?#??.?##?????????? 3,8,1,1 +?#??...????? 4,2 +?#?...?????###??#..? 1,8 +???.#????? 1,3 +#????.?.?????##??? 1,1,4,4 +??##?.????..# 3,1,1,1 +???#????#?#. 2,8 +?#?#??????? 5,3 +??#???.??????#?#? 3,1,1,4 +????#??#????.?? 1,8,1 +?#????.?????#??? 4,1,2 +???.?#??#??#????#? 2,13 +??.???#???#??. 1,1,1,3 +.???#?#?.?. 3,1 +.??#???????.#?. 9,1 +?.??#?#??.?? 2,1,1 +?.?#??..?#?..?# 1,3,1,1 +.?.#?#?.??????????? 3,2 +?#??.??##??? 3,5 +???#?????. 1,4 +???#?#??????##????.? 9,2,2 +.?????#?????# 7,3 +??#####??? 6,1 +??#??..###???? 5,6 +.???#??.?#?????. 5,2,2 +????#?.???###?#?? 2,1,9 +??????#.?#?# 4,2,1,1 +.?????.#????#?? 1,1,3,3 +??#???#.?.??.? 6,1 +?????#?????##??? 5,7 +#???.??.???.?????? 3,1,1,1,1,2 +??.?????##????#..? 7,3 +.???.????###.#? 1,2,4,2 +?.?.#???.????????.?# 1,1,2,2,2,1 +##?.????.????#????. 2,3,7 +#?#?####????.??..?? 1,9,1,2 +?#??#...#?.. 4,2 +.???.?#???#.???.??? 2,2,1,1,1,2 +???????.???????##?. 1,4,1,2,5 +??..??#?#????#?? 1,1,10 +??#?..?#?#??##?. 2,8 +##?###??????.#??# 12,1,1 +?#???.?.???? 2,1,1,1 +?#??.#???#???. 4,1,4,1 +?#?##??????? 2,2,2,2 +???#?#?##??.#??? 1,7,1,1 +???#???#??#? 2,7 +?###.#?#?? 4,4 +??.???#????.#? 2,6,1 +????#.?#????#?#?#?#? 2,1,1,10 +?#?..???????#?.? 2,9 +?.#?#?...#???##??.?? 4,1,3 +.?????.?.???#?#.? 3,3 +.??#??##??? 2,4 +.?.??.??.?#? 1,1,1,1 +#.????#?#. 1,1,4 +.?.?????#?????.? 6,2 +.????.???????.#?##?# 1,1,1,5,4,1 +.?#??..#...?##?? 3,1,4 +####?.??????.???.?? 5,4,1,3,1 +?#.?#?##?#????????? 1,11,1,2 +#??????#??#????.# 12,1,1 +.?##???##???#?#?? 4,3,4 +?..??.?.???? 1,1,1,1 +?????.?????????? 1,1,2,1,4 +?.#??????.??##?## 1,1,1,1,7 +?.??.?????#???? 1,1,1,2,2 +??????????? 5,3 +????.???#??? 1,6 +.?##????????.# 8,1 +?#???...?#??? 2,2 +?????.#?????. 2,1,3 +??????#??? 5,1,1 +#?#?????????? 10,1 +??????????#?? 1,1,2,1 +???#???#??????????? 14,1,1 +.?..?#??...#??. 1,1 +???.#?#?#? 1,1,3 +???????#?#??.?#??? 3,2,2,2 +..???..#??#. 3,4 +????#?#??#.??..?###? 1,1,1,4,1,5 +?#??.????#???#. 1,9 +?.??.?#??.??#????.?. 2,3 +.????.???#?.? 1,4 +.???#?#?##???#???#? 9,2,2 +?#????##.? 2,4 +?.?#??##????.??##? 1,7,1,5 +????????????##??#?? 6,6 +?.??#?##?.? 1,1,4 +??##??#???##??? 11,1 +??#???????# 2,6 +??#?#???..?.???# 7,1,1 +.??????#??#?????? 1,1,8,1 +????#???.?#?#???? 2,1,2,7 +????#???###.??? 1,1,4,1 +????#??.??? 1,1,1 +?.??###??#????.? 6,1 +??#????###?#?? 3,7 +???.??#?.??#?#???.. 2,3,7 +?????.?.????.. 1,3 +???##?.?.??? 1,3,1,2 +???.#????.??? 1,1,5,1 +????.????## 2,6 +#?.?#?????..?##..? 1,6,3 +?.????#?????#?? 3,3 +?#.??#?#?#????.#? 2,9,1 +??????.??. 2,1,2 +?.????#??.?? 1,1,3 +.?.##???????? 4,3 +??#???????###?##??? 1,1,1,1,7 +??#????.??#.?#?? 3,3,1 +#?..???#????? 2,1,7 +?.?#??#????? 1,1,1,1 +..??#?????#???? 6,4 +.##???#???????. 8,1 +???????..?#??? 1,2 +????????????????? 2,1,9,1 +?..????????#???#?#. 1,1,11 +?#?.?????#??????#?? 1,5,5 +??#?#??#?#??? 1,3,1,3 +?#.?##??????..#?.#?? 1,9,1,1 +??.?.?#?.??? 1,1,3,3 +?#?##?????#? 1,2,6 +?#?#??#?#?..#. 4,5,1 +??#????.?? 2,1,2 +???#.??????##???..?? 4,7,1 +#??????????????? 1,6,5 +?#?#????.#?#??.??? 4,1,3,1,1 +.?##??.???? 3,2 +????#?????##.#????? 4,2,4,1 +?.?.??#?#??? 1,8 +?????#?#?#????? 2,10 +???????##????.#? 1,1,1,6,1 +.#?#?.???????#??#??? 3,10,2 +??.#..#..??? 1,1,1,1 +.??#??##??.?????#? 6,1,1 +..???????????#. 1,6,2 +???????#??. 1,5 +???????##????????? 1,1,5,2,1,1 +??#??.????? 3,2 +???##?#????? 1,8 +??.?.??#..?##?????.? 3,7,1 +??????####??#.?.##?# 1,1,4,1,2,1 +????#???#?????????.? 7,7 +??#?????#??? 2,1,2,1 +.??.??.?.?.?...?? 2,1 +???#?#?????.?.?? 9,1,1 +#?....?.????.?.?.?. 1,1,4,1,1 +..??#?#???.. 1,3 +#????#.#???.?? 1,3,3,2 +???#???#??? 4,3,1 +.???#?#?#??.#???#? 2,1,1,1,2,2 +?#?..#?#????##?? 3,3,1,5 +?..???#?#? 1,5 +???#??#?????#???.. 1,2,1,1,1,4 +????.????#??. 2,2 +???????#?.??? 5,2 +#?#?????###?#?#??? 1,3,1,8 +.#????###??? 3,3 +#.??##??#??#?.?? 1,1,9,1 +..??#???#?.??? 7,1 +??#???????.# 3,4,1 +?????#?#???.?????.?? 4,1,2 +?#?.?...#?#??#??? 2,1,1,7 +??..??#..??.???.? 1,2 +???#?##??#?? 1,7 +??#?#??###?????.#?? 1,1,7,1,3 +.?#???#..?#?#??? 1,1,1,3,1 +??????#?##??## 1,4,2 +???#??#.?? 2,1 +.??????##?? 1,1,3 +#?.???###??#????#?? 1,14 +???#?.?????.??. 1,1,1,1,2 +?#???###.?##????. 4,3,4,1 +????.?##???##.?#???# 1,1,8,2,2 +?.###??????#?????? 3,6 +?###?????#?#.?? 4,5,1,1 +?######?#??# 6,4 +???#??????#.? 2,1,2,1 +??.??????. 2,1,1 +??###???.??#.# 7,3,1 +#..?????.# 1,4,1 +?.#?????.?..? 6,1 +???????.???#?? 1,1,2,1 +?.?..????.? 1,1 +?#????..??.?#? 1,3,1,3 +.??#.??.?...# 2,1,1,1 +.????.??##? 3,4 +????.???#??. 1,1,4 +#??#???#?????????? 12,2,1 +.??#???????????? 1,3,1,2,3 +.???....#??.? 2,2 +???#???#..? 1,1,1 +????....#??##?????? 4,9 +?.???#??#? 1,2,4 +???.?.?.#?????.?. 1,6 +??..#??##.#.????. 1,5,1,1 +??#??????? 2,1 +????#??..#.#. 1,2,1,1 +?.#????##??#?.? 1,1,7 +.??##???#??.. 1,4,1,1 +??#??????#?..??#???? 8,2,1,1,1,1 +???.??.?##?.?..? 3,1,4,1,1 +#??##??.##????? 2,3,5 +?????##?#?.???#??. 8,3 +???#??????#?#??#???# 6,12 +??#?.?????? 3,5 +?.?#??????#? 1,7,1 +.??##?????????#? 3,9 +.??#???????.?#.?.. 7,2 +??????#?????#??# 1,2,1,1,1 +?#???#??#?.##??.. 6,1,3 +.???#?..?.???.. 3,1,2 +.###?###?????.? 7,1 +.?#?#?#?#????..? 2,9 +.?????.???????? 1,7 +?##???..?#??#??##?#? 5,12 +.#???.?#?#..?#?????. 4,1,1,7 +?.#????..?.?????#?.? 1,6 +..#?##?????#? 1,2,1,3 +???.????????#.?. 3,1,3,2,1 +???#.##??#?.?# 1,6,1 +?#.?#?.??#?#? 1,3,3 +.?##??.???##????? 3,1,4,2 +.??????#?? 1,1,1 +#???#..?.## 5,2 +????.?###?? 2,4 +??.?.#????? 1,6 +????#???????#.?#?.? 1,1,3,1,2,1 +???##??##???..?? 9,1,1 +?#.???##?. 1,1,2 +?.??#?#?.?.?####.?? 1,1,1,1,5,1 +?????#???###????? 2,2,3,1 +?##????.?#??.#???? 7,1,1,1,2 +???.??#??? 1,3 +..#???#???.?#?.#???? 1,1,4,2,4 +?##.?##.?. 3,3 +????#???.?#?##????. 4,1,7,1 +?????#..??? 4,1,2 +??#????#.?????????? 3,4,5,1 +???????.?? 1,1 +????#???#.#??? 1,6,1,2 +??#?.???#?#?.??#? 3,7,1,1 +???.#?????### 1,9 +##...??#??? 2,1,4 +.?.?????????..??? 3,1,2,1 +?#??#?#???? 7,1 +????#??.??? 4,1 +.?????.#????#??# 1,1,1,1,4 +?..??.???????#?#???. 1,1,1,1,5,1 +?.???.????. 1,1,3 +??????????? 1,1,2 +.#.??#.??..??? 1,2,1,1 +.#???#?????. 6,1 +????.?..?# 1,1,1 +.??##?.??????? 2,1,2,1 +?.???????? 2,1,2 +??#?#????##???#?? 11,1 +?#.?????#? 2,1,2 +.#???#????.?.?##? 6,1,1,4 +??#?#?#????#. 7,1 +#???.#??.#??????#?.? 4,2,9,1 +??????.??#?. 4,1 +?#??.???????. 1,4,1 +????.??.??.?# 2,2,2,2 +????#??.?#? 7,2 +..?#???.?????.????? 5,1,1,2,1 +.??#????.#?#?..? 4,4 +??#????#?.???. 2,4,1 +??????????.? 1,2,4,1 +?..#..#?#..??## 1,3,4 +#??????#?#?.#??????? 1,1,5,1,6 +?#.?.#???. 1,2 +?#?##.?#.#?.???#? 4,1,1,1,3 +?..?.?.#?.?? 1,2,2 +???#?????? 2,4 +?.#????#???#???##. 1,13 +..???#?#??##?..#?##? 6,2,5 +.#?.??#.???# 2,1,1,1 +??#??.?????. 3,1,1,3 +??#?#.?#??#.?#?#. 1,3,1,1,3 +.?..?.??????.? 1,1,5,1 +.?????##??? 1,1,3 +??#...?.??#?#???#? 1,1,1,3,1,1 +?#??.?#?##??.? 1,1,5,1 +?..#???#?????. 1,2,3 +?#??##????#?#??? 6,4 +?#?????#?.?? 1,5,1 +?.#???##???...? 2,5 +??.???????? 1,5 +??????.??#.? 3,1 +?.#???#?#????#??#?? 1,1,4,6 +?.#?##????#?? 4,3 +??##??#??????#? 11,2 +??#????#????? 3,6 +.????#..?? 3,2 +?..??#????#? 1,1,4 +.??#?#?????? 7,1,1 +?????.????????# 2,1,4,4 +#??????##???? 1,1,5 +?????.???##?##?#???. 4,9,1 +?#?#???????? 8,1 +???????#??#?#?## 1,1,10 +?..?.?#.?#?#.???? 1,1,4,1,1 +??.??..??. 1,1,1 +.?.???.??#? 1,2,2 +.?.?#????##?##. 1,5 +?.??#####???#??#??.. 5,5 +.??##.?.?#. 3,1 +?##???.?#. 5,1 +??##???.??#?#??#.?.. 6,7 +???#.??.???# 3,3 +?.?.???##?????? 1,6,1,1 +#????#???# 1,2,1 +??.?.?????#???# 1,1,1,1,1 +?#???.???????.#? 4,1,1,2,2 +.??##?..?##?????#.? 1,3,9 +????#?????#? 2,1 +?.?##??????? 1,6,1 +.###??#?.?#??# 3,2,4 +????###??? 1,3 +??????#??????????? 1,7,3,2 +??#.?##?#. 2,4 +?..??????. 1,1,1 +???.??#?#??#?????# 2,1,8,1,1 +?.#???????.????. 7,1,1 +.#.?#?###.##??????.? 1,1,3,2,4 +??.???.??#??##?#?. 1,8 +..?#??#?????#?.. 5,1,1,2 +?.??????.??????? 1,4 +????????#.??#?##.# 1,2,2,4,1 +?.??.?.??##?.. 1,5 +..?.??.#????#?? 1,2,1,4 +??#?.?.###?.??#?? 2,3,3 +????###????#???#? 6,1,1,1 +??#?.?##????????? 3,7 +???????.???? 1,2,1,2 +??#????##?.???#??? 1,7,2,1,1 +.?.?....???###?...?? 1,6 +.?#???##????? 3,7 +???????#??? 1,4 +#?#.?#??#. 3,5 +.?#?????.?.??# 1,2,1,2 +????.#?#???#??#?? 1,11 +?##????.##???? 7,3,1 +#???#?????#?#?#??? 1,3,1,9 +..?????#?.?????? 7,1 +???#??#??##????#??? 1,1,2,8,1 +????????.???? 6,2 +.????#????????#?? 4,4 +.?????##?? 2,4 +.??.???.?????.#? 2,1,2,1,1 +???.##.##..##? 1,2,2,2 +??###.?????????????? 5,1,2,1,5 +?????#?###??.. 2,1,3,1 +?.????#?#??.?.?? 1,3,2 +??#.??#??. 1,5 +?#?..???#?## 3,1,5 +?#..?#????? 1,1,2 +.???#????#. 3,2 +?????????###? 2,4 +.?##??#????.? 8,1 +.#???#.??#? 5,1,1 +?#??.??..??????? 2,2,6 +#?##???#???? 5,5 +?.?.??#????#??#??. 1,1,7,1 +.##??..#?.?? 2,2 +????##.????.? 3,2,1,1 +?..????#?#?#.???.??? 8,1 +???#??.????..?.? 1,4,1 +.??.??.#????####?? 1,1,9 +??#?.??#?.??? 3,4,2 +??#?????##. 3,4 +??#?#..??#??? 1,1,2,1 +???.??##??##???#? 1,10,2 +.#??.?###?.#????#?. 3,4,3,2 +?#?..???????.?#?? 1,5,2 +????????#?????.? 4,4,3 +????.#??.?.?? 4,3,1 +..##.?????. 2,2 +.???????#??? 2,4 +?.????#.??###?# 1,1,1,3,1 +#?#??????.#?#.?? 5,1,1,1,1 +##???.#?????.???#?# 2,1,4,1,4,1 +.##?#?..??## 2,2,4 +?#?????.??#??#??#?. 1,1,1,8 +#????????#????##? 1,2,7,3 +#..#??.??? 1,2,3 +???#??#?#?# 4,3,1 +#?.?##???? 1,4,1 +??????.??.. 3,1 +???????#???..?? 2,1 +?##????..??# 5,3 +???#..??#? 1,1,3 +???...???? 1,1,1 +????..???.???.. 1,1,1,1,2 +??.??##??# 1,7 +??????.???#???? 2,1 +?????????.#??.?? 6,3 +??.????.?. 1,2,1 +#####?????# 5,1,1 +?????#.?##?#?#????#? 6,5,1,1,2 +??#??##???? 3,6 +?????.??.?.????#??. 1,2,2,1,7 +??????#??.#?.??? 3,2,1,1,1 +??#????#?#? 3,1,4 +??????#.?????#????? 1,4,6,3 +#???.?#??.#???? 4,2,1,1,1 +?..?.##?.?.??.??#??? 2,6 +?????????.???? 1,4,1,1 +.?.??#?#??????????? 8,2,2 +#.#?????..??????#? 1,1,1,1,1,3 +??.??#??????? 2,3,2,1 +??.?.???????? 1,2,1,1 +.??.?##????? 1,3,1,1 +?????.?????? 2,2,2,2 +?????#.???#.?# 4,1,1,1 +??????#??.?????? 1,6,5 +#?.?.??#?##??#?#? 1,12 +??#?##??#?.???? 5,2,2 +#???#??..????#??? 7,1,3 +????????#?#??#???.?? 12,1 +??.?????..????? 1,2,1,3 +?.??#?????#?#????# 1,15 +.??????#?##?.??? 1,8,1,1 +.???????#.?# 5,1,1 +?#?##???#????#???#?? 8,3,3 +????????#???#. 3,2,1,1 +#???#.?#??? 1,2,5 +??????.??##?. 1,1,1,2 +?#.??#?#???? 1,4 +#????#???? 2,3 +?.#?#.?##?#????.?? 1,1,2,2,1,1 +???????#?#.#??#.??# 1,8,1,1,1,1 +?#.#???###?? 1,1,5 +.??.#????#??#?#????? 1,1,12,1 +?#??.???.?. 2,1 +?#.?#.?#??? 1,1,2 +?#?#?.???? 3,1 +?#??#?????#. 3,1,3,1 +???#?##?##??? 1,7 +#.?????????????? 1,1,8,1 +..??.????.?? 1,1,1 +???.???#????.???? 1,6,1,1 +?????#???? 1,5 +.?#.???#???. 2,1,1,1 +???#???.??#?. 6,1,1 +.????#???#??.?.??#? 6,1,1,2 +?????????? 1,3 +.?###?#???. 6,1 +?????.#????#????#?? 1,1,2,1,8 +??##?#??#?.#?#?. 7,3 +???#????#?? 2,1,1 +.?.#??#????.??.??.?. 4,1 +??.??.????.?? 1,1 +???.???#?.??????? 1,3 +???.?.??#????. 1,1,3,1 +#????????? 3,1,2 +.???###.?.???? 3,1 +???###??????#..??? 6,2,1,1 +???##???????? 9,2 +#.???#?.?# 1,2,1 +#.?#.?##???#????# 1,1,7,1,1 +????????#???#??? 2,6,5 +???##.??#?#?#?? 2,7 +???????.?.???.# 2,1,1,1,1 +??.??#?###?##???#.# 1,14,1 +??#?##????? 1,7 +???????.?#?????#??#? 3,1,11 +.??.???#????.??##??? 7,4 +????#??.?? 1,3 +????#???.??.???..? 6,1 +.?.#..#??.?# 1,1,3,1 +.??????.?? 6,1 +##????#??.# 7,1 +.???#?.??????.#? 4,3,1 +?#????.#?.##?? 1,1,1,3 +????.??#???? 2,5 +#??#??????? 6,1 +??????#???.????? 2,6,1,1 +????#???????????# 7,1,1,1 +?.##?.#???.# 3,2,1 +?.????.?.#?? 2,2 +???#????#????. 1,2,7 +?????.??#????#? 4,3,2 +????..??#??.?#??. 4,3,3 +#??.??#???#???#????? 1,1,4,9 +#????????? 6,1 +????????#.?#?? 1,1,2,4 +.?#?.#???.???#?#? 1,4,5 +??#??#???#?.????? 8,1,1,2 +???.??##?#?#???# 1,10 +???.?????. 1,1,1 +??..?#??????#?#?#??? 1,11 +#???#.?#?. 3,1,3 +??#?##?#??##??.?.?? 11,1 +??.?.??.???#?. 1,1,1,3 +.?#??#???.???. 2,1,1,2 +?#?..??#?? 2,5 +??#???#???#???. 3,8,1 +..????????. 3,2 +?????##.?#??#? 1,3,2,1 +?????.???.?#????? 2,2,1,6 +.??#?.???#??????..? 3,5 +????????###.?. 4,3 +?###???#??????????#. 8,4,5 +?#?.#?????????? 2,7,1 +???#????#??.?.??? 6,1,1,1,1 +??????????.#? 8,2 +???#?.??#???. 1,3,1,2 +?.??.??#.?#??.?? 2,3,1,1,1 +#????.??#.?#?????.? 1,2,3,6,1 +#???????#???# 6,1,1 +.?#???.?#? 5,1 +??????.????????????? 3,4,7 +.#.??.?#??#????.??? 1,1,9,3 +?.???#?#??. 1,1,4 +??#???##?..??#?? 9,2 +??.??.?????##?.??. 1,1,1,5,1 +??.??#??.#?????#?#?. 1,5,2,5 +.?##???##??.?? 3,5 +?#??#???.?????.??? 7,1,2,1 +????.?#???. 1,5 +?#????#????.#??? 10,1,1 +#.?####?.?. 1,6,1 +?#.??#?.??? 1,3 +.??????#?.?##? 2,4,3 +??##?????????????? 3,10 +.?.???.#?.?#????. 1,1,2,1,2 +.????.?##?.????##? 4,3,7 +?????????? 1,3 +?.#????.#?.??? 1,2,1,1 +????.?#.?. 1,1,1 +###?.?##?####?????? 4,3,7,1 +??.?????#.#???? 1,4,1,1 +?.?..#??#??? 1,5 +#??#???.?#? 2,2,1 +.?.?#?.?..?. 1,1,1,1 +#?..?#???##????? 1,7,1 +???#?????.#??# 9,1,1 +?#????????.??. 6,1,1,1 +???#?##???.???#??? 1,7,1,4 +#?#?#???????????#? 1,3,2,2,1,1 +...#?.???#..#? 1,2,1,2 +??#????.??#???#?#?.. 7,3,5 +???###.??#??#?? 6,4,1 +.??????#.#????.#. 6,1,1,1 +??????####????#.?.? 5,4,1,1,1 +##??#???#?##??#???? 15,1 +?#?.????.???.#.? 3,1,1,1,1 +??.??#????#?.?? 1,3,3,1 +?#???????.???#?#???# 5,1,8,1 +#?.???.??#? 2,1,4 +????#??????? 2,2,2 +.????.#?#?##??. 1,1,1,1,4 +????.????????#?#? 1,2,9 +??????#.##??? 2,2,3 +.?????#???.??? 2,4,1 +.?????#???#???# 3,10 +???##????#.??.? 5,1,1,1,1 +??#?.#??#???.####?? 1,1,1,4,6 +????#????.?.??#?? 6,4 +??..?.?.?..# 1,1,1,1 +??????????#? 1,1,1,1 +??##????#..?.????##. 4,3,1,1,2 +.?#?.?.??.#???????# 1,1,1,1,1,4 +?.?#..?#?#?#?#? 1,8 +.#...??#??##?#???? 1,11 +??.#???.???#??##?? 1,5 +???????????? 1,1,5 +?????????#?????.?. 3,1,2,3,1 +?#?????#...? 2,3,1 +??.????#??????????.# 1,6,1,1,1,1 +?.?#???#?#.?#?.. 3,3,2 +?##???..##? 5,2 +??.?.??#??? 2,1,5 +??#???.???.?#. 2,2,2,1 +???#??????????.?? 5,1,1 +###?.???#?? 4,4 +??.??#?#?????.???? 1,5,1,3 +??#??#?.??# 6,1 +?.#?#?##?.####.??.# 1,3,3,4,1,1 +?#???.????#?#?###? 3,12 +????..?????? 1,1,1,1 +?.?#?.#?#??##???# 1,2,7,1 +????..??????#?. 1,1,3,1,2 +??##????.??#?.??. 4,1,1,2,2 +.????.????#???? 3,1,3,1 +?.?????##?????.??? 10,1 +?#??#??#????#???#. 1,5,1,3,1 +#?.?.????###?.#???# 1,1,7,1,1,1 +.#??#??????#???# 1,2,7 +??.###?????? 1,3,3,1 +???#?.????#??.?.??? 3,4,2 +??????###?#???#??#?. 1,13 +#?.#?????#??????? 1,1,1,1,6 +#??.???..?? 3,3,1 +.???#??#??????.? 1,5,3 +#?#??#???##?.???.# 11,2,1 +?#???.#?.??#??? 1,1,1,3,1 +?#??##?##?.?? 2,5,1 +?.##???.???#?? 4,5 +?.?##??#???? 1,6,1 +?#?###.???#????#?#?# 6,10 +##.?..??.?? 2,1,1 +??.????????????. 4,1,2 +???..#????#??????.? 7,2 +#.?#??????##? 1,2,1,3 +.??#????#...#?.? 7,1 +?.?#????####???.?? 1,1,10,1 +?#??#?#???..????? 8,5 +???#?.??????# 5,1,2,1 +.??.?##??? 1,3,1 +??.????????? 1,2 +??#.???#?##??#.? 1,1,8 +?????.#??#???###?.? 1,1,4,5 +#??##?????.#??#?? 7,1,2,1 +##?#?.#.??????????? 5,1,2,1,1,3 +?##?#.???????.?#.??. 3,1,6,2,1 +.??.???????#?#?#?# 1,1,1,5,3 +???????????.??. 4,1,2,1 +?#.????#????#?.?.? 2,10,1 +.?#.?????? 2,1,4 +.??#?#.??????..? 5,3 +??????#???????..??? 5,2 +???????##??#??????. 8,1,3,1 +#?#..?#?????#?#?#?#. 3,12,1 +?????#???#?..#??? 5,1 +???#?#??#??.??##???? 1,2,1,3,8 +??#.?.???????.#???.# 3,1,5,1,1 +?????????. 1,1,1 +??.??????#.#?#?#?#?? 4,1,3,4 +?#?#.???????.?.???? 4,1,4,1,1,2 +?#?..?##???#.? 1,3,2 +??#.#.?#??.?? 1,1,2,1 +#?#????..???.?#.? 7,3,2,1 +?#.?##??##?? 1,8 +??????#?#??... 2,7 +?????#?.??#?. 7,1,1 +#?.?????#???..?.??? 1,4 +?#?#??##??????????? 15,1 +??.#?#??#.????????? 1,6,1,1,1 +????##??#.?#?? 7,1 +?.##.????##??????? 2,7,3 +?????.?.##??.? 2,3 +??..????#???????? 1,1,3,1,4 +?.#????..??????#?. 1,5,5 +??#?#????.?#?? 1,3,1,2 +?#??????#??#??????? 3,1,5,1,3 +?.???.?.#??.????.? 2,1,3,2,1 +.?#????.??.#?.#?#?? 3,1,1,2,1,3 +???#??#???????? 1,12 +??????.#?#???##? 1,5,2 +??????##?..??????? 3,4,1,2 +?#???#??.???.#?#?? 3,3,1,3 +???#????.??.. 2,1,2,1 +#??###??##??? 1,7 +??.??.?#.???????.?? 1,1,1,4,1,1 +??????????#??? 2,1,7 +???.??#????#? 1,7 +??????????#? 1,2,2,1 +?##???##???????#???# 3,3,8,1 +?.#????#??????.# 2,3,3,1 +?.?#??#..?.?.??? 1,2,1,1,2 +???#?????. 4,1 +..?#.??????##??# 1,1,5,1 +????#?##??.?? 8,2 +?#.?.????????#??? 1,1,1,3,6 +?.?..#???#???#..??? 9,2 +?#?.???.?????.???? 2,5 +?###????#?#???#?? 4,5,1,2 +???.??.??????...# 1,2,4,1 +#???#.????#?#??##? 5,9 +??.????.?#??. 2,1,1,1 +#.?#???.??????? 1,1,2,1,5 +#?#??..?.#??#? 5,1,5 +?#?????#???. 5,2 +??.????????#?#?. 1,1,1,1,3 +#???????#??##?#?#?. 1,9,1,1 +????.#?#.#?##?? 1,1,1,1,5 +??.?#???????#?? 3,8 +???#??.???.? 4,1 +?#????????.??? 1,1,1,3 +??..???#.?.? 2,3,1 +?#???#????#?????. 3,11 +?.??.???##.?#? 2,4,1 +?????.?#.???????.? 1,2,1,1,2,1 +.????.?#.?.?.#????.? 2,3 +.#?###??#???. 6,4 +??#?#???.? 6,1 +?.???##?#?. 1,5 +???????????.??##?. 1,6,1,1,3 +?.?#?.?.?????#??? 1,2,1,1,3 +??????#??##?.#. 2,2,2,1 +.??#?#?.#??.??? 4,2,1 +.????.?#???.????.??. 3,3 +???#.????#???? 3,4,1 +?????#????#???..??? 10,1 +?#???????#?????? 1,1,4,1,1 +?#?##?#?????###? 9,5 +?.####?###???#?? 12,1 +?#??#?#?..?# 5,2,1 +????#??.?##? 1,1,1,2 +??????????? 2,1 +??.?##.????##?? 1,3,6 +.????#?.##???#??. 1,4,3 +?.???????#?##??#? 1,10 +##??.??#???. 4,5 +????##???#??????. 6,2,1,1 +???.??#??..??#??.?## 1,3,5,3 +????.#?#??.?? 2,5 +#???..???.#. 1,2,1,1 +???.??#.??.# 1,2,1,1 +???#??????. 4,1 +?????#???#????#.?. 1,9,2,1 +??#??#?????#?.? 8,1 +??#??.???#??#?????.# 2,10,1 +?????#?##?#??.#?#? 11,1,1 +?#???.#??##??##??.? 1,2,5,4,1 +??.???#?#??#?.? 1,6,1 +?#..???????.?????.#? 2,7,2,2,1 +??.???????##? 2,1,1,4 +???######??.??. 8,1 +?????#????# 1,5,1 +#?###?.??. 1,4,2 +?????????????.? 1,1,2,1,1 +#??.????.?##??? 2,1,3 +.???.#????.????#? 2,5,3,2 +?????????#?? 2,2,1 +??##?.?#?.?? 2,3,1 +??####??#??.#?.??? 8,1,1,1 diff --git a/2023/day12/main.go b/2023/day12/main.go new file mode 100644 index 0000000..6a2c40d --- /dev/null +++ b/2023/day12/main.go @@ -0,0 +1,109 @@ +package main + +import ( + "fmt" + "strings" + + h "git.bullercodeworks.com/brian/adventofcode/helpers" +) + +func main() { + inp := h.StdinToStringSlice() + part1(inp) + fmt.Println() + part2(inp) +} + +func part1(input []string) { + var records []string + var groups [][]int + for _, ln := range input { + pts := strings.Fields(ln) + records = append(records, pts[0]) + var grp []int + for _, n := range strings.Split(pts[1], ",") { + grp = append(grp, h.Atoi(n)) + } + groups = append(groups, grp) + } + var result int + for i := range records { + // Initialize cache for this row + cache := make(map[string]int) + + // And solve the row + result += solveRow(0, 0, records[i], groups[i], cache) + } + + fmt.Println("# Part 1") + fmt.Println(result) +} + +func part2(input []string) { + var records []string + var groups [][]int + for _, ln := range input { + pts := strings.Fields(ln) + // Unfold the paper + pts[0] = fmt.Sprintf("%s?%s?%s?%s?%s", pts[0], pts[0], pts[0], pts[0], pts[0]) + pts[1] = fmt.Sprintf("%s,%s,%s,%s,%s", pts[1], pts[1], pts[1], pts[1], pts[1]) + records = append(records, pts[0]) + var grp []int + for _, n := range strings.Split(pts[1], ",") { + grp = append(grp, h.Atoi(n)) + } + groups = append(groups, grp) + } + + var result int + for i := range records { + // Initialize cache for this row + cache := make(map[string]int) + + // And solve the row + result += solveRow(0, 0, records[i], groups[i], cache) + } + + fmt.Println("# Part 2") + fmt.Println(result) +} + +func ck(i, j int) string { return fmt.Sprintf("%d_%d", i, j) } + +func solveRow(rbIdx, groupIdx int, record string, group []int, cache map[string]int) int { + if rbIdx >= len(record) { + if groupIdx < len(group) { + return 0 + } + return 1 + } + if v, ok := cache[ck(rbIdx, groupIdx)]; ok { + return v + } + res := 0 + if record[rbIdx] == '.' { + res = solveRow(rbIdx+1, groupIdx, record, group, cache) + } else { + if record[rbIdx] == '?' { + res += solveRow(rbIdx+1, groupIdx, record, group, cache) + } + if groupIdx < len(group) { + count := 0 + for k := rbIdx; k < len(record); k++ { + if count > group[groupIdx] || record[k] == '.' || count == group[groupIdx] && record[k] == '?' { + break + } + count += 1 + } + if count == group[groupIdx] { + if rbIdx+count < len(record) && record[rbIdx+count] != '#' { + res += solveRow(rbIdx+count+1, groupIdx+1, record, group, cache) + } else { + res += solveRow(rbIdx+count, groupIdx+1, record, group, cache) + } + } + } + } + cache[ck(rbIdx, groupIdx)] = res + return res +} diff --git a/2023/day12/problem b/2023/day12/problem new file mode 100644 index 0000000..8c0589d --- /dev/null +++ b/2023/day12/problem @@ -0,0 +1,222 @@ + [1]Advent of Code + + • [2][About] + • [3][Events] + • [4][Shop] + • [5][Settings] + • [6][Log Out] + + br0xen [7](AoC++) 24* + +    sub y{[8]2023} + + • [9][Calendar] + • [10][AoC++] + • [11][Sponsors] + • [12][Leaderboard] + • [13][Stats] + + Our [14]sponsors help make Advent of Code possible: + [15]Tailscale - Secure remote access, powered by WireGuard. Replace your + VPN :) + +--- Day 12: Hot Springs --- + + You finally reach the hot springs! You can see steam rising from secluded + areas attached to the primary, ornate building. + + As you turn to enter, the [16]researcher stops you. "Wait - I thought you + were looking for the hot springs, weren't you?" You indicate that this + definitely looks like hot springs to you. + + "Oh, sorry, common mistake! This is actually the [17]onsen! The hot + springs are next door." + + You look in the direction the researcher is pointing and suddenly notice + the massive metal helixes towering overhead. "This way!" + + It only takes you a few more steps to reach the main gate of the massive + fenced-off area containing the springs. You go through the gate and into a + small administrative building. + + "Hello! What brings you to the hot springs today? Sorry they're not very + hot right now; we're having a lava shortage at the moment." You ask about + the missing machine parts for Desert Island. + + "Oh, all of Gear Island is currently offline! Nothing is being + manufactured at the moment, not until we get more lava to heat our forges. + And our springs. The springs aren't very springy unless they're hot!" + + "Say, could you go up and see why the lava stopped flowing? The springs + are too cold for normal operation, but we should be able to find one + springy enough to launch you up there!" + + There's just one problem - many of the springs have fallen into disrepair, + so they're not actually sure which springs would even be safe to use! + Worse yet, their condition records of which springs are damaged (your + puzzle input) are also damaged! You'll need to help them repair the + damaged records. + + In the giant field just outside, the springs are arranged into rows. For + each row, the condition records show every spring and whether it is + operational (.) or damaged (#). This is the part of the condition records + that is itself damaged; for some springs, it is simply unknown (?) whether + the spring is operational or damaged. + + However, the engineer that produced the condition records also duplicated + some of this information in a different format! After the list of springs + for a given row, the size of each contiguous group of damaged springs is + listed in the order those groups appear in the row. This list always + accounts for every damaged spring, and each number is the entire size of + its contiguous group (that is, groups are always separated by at least one + operational spring: #### would always be 4, never 2,2). + + So, condition records with no unknown spring conditions might look like + this: + + #.#.### 1,1,3 + .#...#....###. 1,1,3 + .#.###.#.###### 1,3,1,6 + ####.#...#... 4,1,1 + #....######..#####. 1,6,5 + .###.##....# 3,2,1 + + However, the condition records are partially damaged; some of the springs' + conditions are actually unknown (?). For example: + + ???.### 1,1,3 + .??..??...?##. 1,1,3 + ?#?#?#?#?#?#?#? 1,3,1,6 + ????.#...#... 4,1,1 + ????.######..#####. 1,6,5 + ?###???????? 3,2,1 + + Equipped with this information, it is your job to figure out how many + different arrangements of operational and broken springs fit the given + criteria in each row. + + In the first line (???.### 1,1,3), there is exactly one way separate + groups of one, one, and three broken springs (in that order) can appear in + that row: the first three unknown springs must be broken, then + operational, then broken (#.#), making the whole row #.#.###. + + The second line is more interesting: .??..??...?##. 1,1,3 could be a total + of four different arrangements. The last ? must always be broken (to + satisfy the final contiguous group of three broken springs), and each ?? + must hide exactly one of the two broken springs. (Neither ?? could be both + broken springs or they would form a single contiguous group of two; if + that were true, the numbers afterward would have been 2,3 instead.) Since + each ?? can either be #. or .#, there are four possible arrangements of + springs. + + The last line is actually consistent with ten different arrangements! + Because the first number is 3, the first and second ? must both be . (if + either were #, the first number would have to be 4 or higher). However, + the remaining run of unknown spring conditions have many different ways + they could hold groups of two and one broken springs: + + ?###???????? 3,2,1 + .###.##.#... + .###.##..#.. + .###.##...#. + .###.##....# + .###..##.#.. + .###..##..#. + .###..##...# + .###...##.#. + .###...##..# + .###....##.# + + In this example, the number of possible arrangements for each row is: + + • ???.### 1,1,3 - 1 arrangement + • .??..??...?##. 1,1,3 - 4 arrangements + • ?#?#?#?#?#?#?#? 1,3,1,6 - 1 arrangement + • ????.#...#... 4,1,1 - 1 arrangement + • ????.######..#####. 1,6,5 - 4 arrangements + • ?###???????? 3,2,1 - 10 arrangements + + Adding all of the possible arrangement counts together produces a total of + 21 arrangements. + + For each row, count all of the different arrangements of operational and + broken springs that meet the given criteria. What is the sum of those + counts? + + Your puzzle answer was 7716. + +--- Part Two --- + + As you look out at the field of springs, you feel like there are way more + springs than the condition records list. When you examine the records, you + discover that they were actually folded up this whole time! + + To unfold the records, on each row, replace the list of spring conditions + with five copies of itself (separated by ?) and replace the list of + contiguous groups of damaged springs with five copies of itself (separated + by ,). + + So, this row: + + .# 1 + + Would become: + + .#?.#?.#?.#?.# 1,1,1,1,1 + + The first line of the above example would become: + + ???.###????.###????.###????.###????.### 1,1,3,1,1,3,1,1,3,1,1,3,1,1,3 + + In the above example, after unfolding, the number of possible arrangements + for some rows is now much larger: + + • ???.### 1,1,3 - 1 arrangement + • .??..??...?##. 1,1,3 - 16384 arrangements + • ?#?#?#?#?#?#?#? 1,3,1,6 - 1 arrangement + • ????.#...#... 4,1,1 - 16 arrangements + • ????.######..#####. 1,6,5 - 2500 arrangements + • ?###???????? 3,2,1 - 506250 arrangements + + After unfolding, adding all of the possible arrangement counts together + produces 525152. + + Unfold your condition records; what is the new sum of possible arrangement + counts? + + Your puzzle answer was 18716325559999. + + Both parts of this puzzle are complete! They provide two gold stars: ** + + At this point, you should [18]return to your Advent calendar and try + another puzzle. + + If you still want to see it, you can [19]get your puzzle input. + + You can also [Shareon [20]Twitter [21]Mastodon] this puzzle. + +References + + Visible links + 1. https://adventofcode.com/ + 2. https://adventofcode.com/2023/about + 3. https://adventofcode.com/2023/events + 4. https://teespring.com/stores/advent-of-code + 5. https://adventofcode.com/2023/settings + 6. https://adventofcode.com/2023/auth/logout + 7. Advent of Code Supporter + https://adventofcode.com/2023/support + 8. https://adventofcode.com/2023 + 9. https://adventofcode.com/2023 + 10. https://adventofcode.com/2023/support + 11. https://adventofcode.com/2023/sponsors + 12. https://adventofcode.com/2023/leaderboard + 13. https://adventofcode.com/2023/stats + 14. https://adventofcode.com/2023/sponsors + 15. https://tailscale.com/advent + 16. https://adventofcode.com/2023/day/11 + 17. https://en.wikipedia.org/wiki/Onsen + 18. https://adventofcode.com/2023 + 19. https://adventofcode.com/2023/day/12/input + 20. https://twitter.com/intent/tweet?text=I%27ve+completed+%22Hot+Springs%22+%2D+Day+12+%2D+Advent+of+Code+2023&url=https%3A%2F%2Fadventofcode%2Ecom%2F2023%2Fday%2F12&related=ericwastl&hashtags=AdventOfCode + 21. javascript:void(0); diff --git a/2023/day12/testinput b/2023/day12/testinput new file mode 100644 index 0000000..e925935 --- /dev/null +++ b/2023/day12/testinput @@ -0,0 +1,6 @@ +???.### 1,1,3 +.??..??...?##. 1,1,3 +?#?#?#?#?#?#?#? 1,3,1,6 +????.#...#... 4,1,1 +????.######..#####. 1,6,5 +?###???????? 3,2,1