diff --git a/2023/day12.py b/2023/day12.py index 992bf35..64a98ab 100644 --- a/2023/day12.py +++ b/2023/day12.py @@ -1,13 +1,107 @@ +import os import sys -from collections import defaultdict -from dataclasses import dataclass +from functools import lru_cache +from typing import Iterable + +VERBOSE = os.getenv("AOC_VERBOSE") == "True" + + +@lru_cache +def compute_fitting_arrangements(pattern: str, counts: tuple[int, ...]) -> int: + """ + fn3p tries to fit ALL values in counts() inside the pattern. + """ + # no pattern -> ok if nothing to fit, otherwise ko + if not pattern: + count = 1 if not counts else 0 + + # no count -> ok if pattern has no mandatory entry, else ko + elif not counts: + count = 1 if pattern.find("#") == -1 else 0 + + # cannot fit all values -> ko + elif len(pattern) < sum(counts) + len(counts) - 1: + count = 0 + + elif len(pattern) < counts[0]: + count = 0 + + else: + count = 0 + + if pattern[0] == "?": + count += compute_fitting_arrangements(pattern[1:], counts) + + if len(pattern) == counts[0]: + count += 1 + + elif pattern[counts[0]] != "#": + count += compute_fitting_arrangements(pattern[counts[0] + 1 :], counts[1:]) + + return count + + +@lru_cache +def compute_possible_arrangements( + patterns: tuple[str, ...], counts: tuple[int, ...] +) -> int: + if not patterns: + return 1 if not counts else 0 + + with_hash = sum(1 for p in patterns[1:] if p.find("#") >= 0) + + if with_hash > len(counts): + return 0 + + to_fit = counts if with_hash == 0 else counts[:-with_hash] + remaining = () if with_hash == 0 else counts[-with_hash:] + + if not to_fit: + if patterns[0].find("#") != -1: + return 0 + return compute_possible_arrangements(patterns[1:], remaining) + + elif patterns[0].find("#") != -1 and len(patterns[0]) < to_fit[0]: + return 0 + + elif patterns[0].find("?") == -1: + if len(patterns[0]) != to_fit[0]: + return 0 + return compute_possible_arrangements(patterns[1:], counts[1:]) + + else: + return sum( + fp * compute_possible_arrangements(patterns[1:], to_fit[i:] + remaining) + for i in range(len(to_fit) + 1) + if (fp := compute_fitting_arrangements(patterns[0], to_fit[:i])) > 0 + ) + + +def compute_all_possible_arrangements(lines: Iterable[str], repeat: int) -> int: + count = 0 + + if VERBOSE: + from tqdm import tqdm + + lines = tqdm(lines) + + for line in lines: + parts = line.split(" ") + count += compute_possible_arrangements( + tuple(filter(len, "?".join(parts[0] for _ in range(repeat)).split("."))), + tuple(int(c) for c in parts[1].split(",")) * repeat, + ) + + return count + lines = sys.stdin.read().splitlines() + # part 1 -answer_1 = ... +answer_1 = compute_all_possible_arrangements(lines, 1) print(f"answer 1 is {answer_1}") # part 2 -answer_2 = ... +answer_2 = compute_all_possible_arrangements(lines, 5) print(f"answer 2 is {answer_2}") diff --git a/2023/inputs/day12.txt b/2023/inputs/day12.txt index e69de29..c6edaba 100644 --- a/2023/inputs/day12.txt +++ b/2023/inputs/day12.txt @@ -0,0 +1,1000 @@ +?????#?#?.?#?#. 7,3 +#??#?#.?.?????? 6,1,5 +??#??????#???.? 4,3 +?.?..?..????? 1,4 +????????.?##???????? 3,1,1,4,1,1 +?#??###?#????#?. 6,2,3 +???..????# 1,3,1 +?#??????#??. 4,2 +??.?????#??#? 2,1,5 +.?#?.###??. 1,5 +?.???#?##?? 1,7 +?#???..?.#? 2,2,1 +????##???#?.??. 5,2,1 +???.???#???? 1,1,3,1 +.##?#????.?? 8,1 +????.?.?#?? 2,3 +.??#??###??#?? 3,4,3 +??#???????. 3,1,1 +??#????.??##?? 2,2,3,1 +??##???.??#???#??? 3,7 +.??#.?????..????#?. 1,1,5 +.???????.??#?? 7,3 +.?#??????.?#???..?? 8,4,2 +.?##?.##??? 3,2 +???#?##??????.???.?? 1,8,1,1 +?#?#?#?.??? 3,1,2 +..??#???.?###????.?. 1,4 +?#?????.??#??##????? 3,1,5,1 +?????##.????????#? 7,6,2 +???#??.?.?##.#???##? 2,3,3,7 +.??#???#.?????????? 3,1,1,1,1,2 +??.?#??#?..?#??? 6,3 +??..????#.# 1,2,1 +???.#?##??? 1,7 +?#??..??????.#? 3,4,2 +??.#??????? 2,5,1 +?.#??#?????.# 1,1,4,1 +?##?#?#???#? 7,1 +???#.??.?.?# 3,1,1 +.??.????.??#??.#?# 1,3,3,1,1 +???#?##??.?.??#?? 8,1,4 +?#...?#??.??? 1,4,1 +?????#.????#??. 1,1,6 +#?????????? 1,4,2 +???.?#??#?.? 2,1,1,1 +?#?#???##? 4,3 +??#???#?#?##???????? 3,12 +.#??#??.?????? 5,2 +?#?#???#?????. 9,1 +#??#?#??##????##?.## 1,14,2 +?#????.????????##. 2,2,10 +.?##.??.?? 3,1,1 +?.??..??#???.?? 1,1,2,1 +??????.?.#.????? 5,1,1,1,2 +?.?#?????? 1,2 +??#####??.#?? 8,1 +?#?#???.#?? 2,1,3 +.??????.#? 2,1,1 +?..???????#????. 4,1,1 +??#?.####?.? 2,5,1 +???#??.?.????.? 4,1,1,1 +.?.??.???#?.?#???.. 1,4,5 +??#?..?#??? 1,2 +.#?????#??#? 2,4 +.?##?.???????? 3,3 +??.#???????#??.? 1,5,5,1 +.?#..???.? 2,1 +??.##???????#.# 1,6,2,1 +??????#?????#??.??? 1,1,3,3,1,1 +?#?????????#??????# 5,4,4 +???#??#??????#???.? 4,8 +?#??????????#?#?#?.? 5,9 +?.?#?#?.??. 4,2 +#.??????.#.?###???. 1,1,3,1,3,1 +???..#??.# 3,2,1 +??#???#????.????? 11,1,1 +?????.#???? 4,1,3 +#.#?.?##??#???? 1,1,3,1,1 +???#????????????# 8,1,2,1 +??????.?????? 1,3 +???.???..???#???? 3,3,3,2 +????#..??#?.?? 1,1,3,1 +??#??.?#?????? 3,6 +??.???#???? 2,7 +#.?#???#.??#.? 1,3,1,1 +?.?????#?#?#..?# 1,8,1,1 +????###??? 1,6 +???.?????.??? 1,2,1,2 +.#.?.???.???.?#???? 1,1,1,1,1,4 +?????#???##?.? 5,3 +.??.???????? 1,1,2,1 +?#?.???#.#??.?? 2,1,2,1,1 +.?#.#?..?? 1,2 +?????.#?##.?.?##. 2,4,3 +.?#?.??????.# 3,2,1,1 +##.?????????. 2,3 +#???????????#? 3,2,2,3 +??????##?##?????? 1,5,3,1 +??????##??#???? 3,6 +..#??????.?#. 6,1 +.?#.##?#.??#?? 2,2,1,4 +???#???.#.?. 5,1 +..????#???#??.#. 10,1 +??#????..?# 5,1 +???????##??? 2,3 +?#?#?????? 3,1 +????#????#?#? 1,2,2,2 +..?.??#???.??. 1,1,2,2 +??#???#??#.??. 4,4 +??##???.#?.?.##? 6,2,1,3 +.??.?#??#???# 1,5,2 +????.?##???? 1,1,2,1 +?#????????????#? 2,6,5 +?#??????.???? 7,1 +#??#??#..?#??? 5,1,1,1 +#?#.#?#????#??? 3,8 +#?#???#.???.?? 3,1,1,1 +???#??#?#?###.??? 12,1 +?.????#???????? 8,1 +?.?#?.???..#????? 3,1,6 +#??????.?????????? 2,1,1,6,1 +????#???.?.??#?## 1,4,1,1,4 +????.???#??#.?????# 4,4,1,2,1 +????.????? 1,1,2 +.?##????#.??.. 7,1 +.?..??#.?? 1,1,2 +??#?#??????#???.#.# 5,2,2,1,1,1 +??????????##??# 1,2,2,5 +??..?????.? 3,1 +???????.#??????? 1,4,5,1 +?#?.?.#?.??? 1,1,1 +??.?.#???#?#?###?# 1,1,1,1,9 +?.?#.???????#.? 1,1,2,1,1 +???#?.?#??.???. 1,2,1,1,3 +.#??..##???.?.?#?. 1,1,3,1,1,2 +?.#?##.???? 4,1 +????#?#???#?#?.#?## 1,11,4 +?.#???#?##?#?#??#? 1,1,8,1,2 +??????#?###??# 3,6,1 +??????.??#??.?#?.?#? 1,1,5,3,3 +...?#?.??..?#??? 2,2,3,1 +?.?#???##??###?##?. 1,16 +..#?#???#???.?##?? 1,3,2,1,3 +??.???????????? 6,2 +?.????.??#??#?##???? 1,9 +#?.#???#????#???#?#? 1,1,1,5,1,1 +#??#?.??.?#..?#?? 1,2,2,4 +?##??#?##??.??.????? 9,3 +??????.??# 1,1,1 +?#???#??.??.?#?? 6,1,1,1 +?#??#??##???.?#. 9,2 +..?????.??. 1,2,1 +??..??#???. 1,5 +.??#?..?????.? 3,1 +?#?????????#?.??.# 1,1,5,1,1 +.??????.##?.?..?#?? 5,2,2 +.???##.#??#???#?? 1,2,2,3,2 +?????.?.?# 5,1 +??????#?????#???#??# 6,6,5 +?#?#.???#????# 4,3,2,1 +??.?.?#????. 1,3 +?..?#??#??.?.????## 1,6,1,1,2 +?#????#????#.? 7,3 +#?.????#?? 1,1,4 +.?.???.??? 1,1,1 +#?#?###?????.? 11,1 +.?????.??#????## 1,9 +.???#?????.#??.?? 7,1,1 +??.????#.?#?.?????? 2,3,2,1,2 +?#?##???#???#???#. 4,7,1 +???????????????# 1,3,1,5,1 +.????#.?###?#??? 4,4,1,1 +#????.??.???#.?? 4,2,1,1,1 +?????#???#?? 4,1 +??????????????#. 8,2 +?????#?????#? 1,8 +#???.?.#??##?.???? 1,1,1,6,1,1 +?#???.?.?? 1,1,1 +??.?#??????#????? 2,3,3,2 +??.?????#??#. 1,2,2,1 +?..?#??????#??.???# 1,11,1,1 +??#????##??###?.??? 1,3,9,2 +????????.???..? 2,2,1,3 +?#.??#???.??#??# 1,5,2,1 +.#.???????#???????. 1,8,4 +?#???###?..??.?.??? 7,1,1 +?.#??.??#?##.??? 1,1,6,2 +...##?#???????????. 2,10,1 +??##.?.???##?.??.. 4,1,1,3,2 +#.??#???.?#????#? 1,1,2,1,6 +??#?#??###?????.???? 14,1 +???????.??.?????? 4,1,1,1,2 +?##???.????.#??#?? 6,1,1,1,1 +??###?.?..?.#?#???? 6,1,1,1,1,1 +#???.##.?? 2,2,2 +.?.#?.#..??#?#???.?. 1,1,1,8,1 +.#?.#???.???#?#? 1,3,5 +#???????????###??? 8,8 +?????#?##?#? 2,6 +###?#?.??? 6,1 +.?#??.????. 3,3 +#???????.?#.??.# 2,5,1,1 +?.#?#???##???.???.?. 1,3,7,1,1 +.?##????#.?#???#? 7,5 +????#.???#?#.#. 3,1,2,3,1 +?.?????#??#.? 4,4 +.??..??#?? 1,4 +#?#?#??.???????#?? 7,1,1,1,1,1 +??#??????????? 4,3 +?#???#???.??..#.???? 2,4,1,1,1,1 +??.#??.???##?.?? 2,1,5,1 +?#??##?.?????..#?? 1,4,1,1,1,1 +?.#??..#..?? 3,1,2 +?????.##???? 4,6 +????..?#???.??### 1,1,3,5 +???????.?????????#?? 1,3,10 +?#.???????????#??.# 2,1,2,1,5,1 +#?#??#???#?.????#?# 3,5,7 +??????##?????????.? 4,3,5,1,1 +?#??.?????.#????#? 1,1,5,2,1,2 +????.??#?????????. 2,4,3,2 +??#.????##?. 2,1,4 +#.???.?????.??? 1,1,3,1,1 +???#.#####?#??##??#? 1,1,14 +??????????.?. 1,4 +.????????.?.???. 3,1 +?#??????..? 3,2,1 +#?#.??..???. 1,1,1,2 +?#??#..????????? 5,5 +.?#?#????##?????.?.. 2,7,1,1 +???????####.????### 7,6 +?..??#????#?#??#?#?. 10,5 +.????#???#??.?#??? 10,2 +?.?#?#?##?.?..??. 8,2 +?.???..?####??#??.?# 1,2,10,1 +.?????#?#??#? 2,5,1 +?.??????.?#??????. 4,6 +?????????.#???????.? 1,1,1,1,1,5 +.????#???.##?#?#??.? 2,7 +?.????##?? 1,5 +?????.?#??? 3,1,2 +.???##.?#.???????.#? 5,1,1,1,2,2 +#????#?.???#? 3,1,4 +.????.??##? 2,1,3 +????.???.?..#?????#. 4,2,5,1 +??..??#?#?#.? 2,5,1,1 +??#?#?..??.??. 6,2,1 +???.????#?#???? 1,1,6 +.????.???.? 1,2,1 +.#.?????.??..#. 1,4,1,1 +?#????#???.?????..?. 2,4,4 +?.??##??#????.??? 1,9,1,1 +??.?.??#???#.#..?? 1,1,5,1,1 +#??#?#??..??.?????. 7,1,3 +#??#?#.##.??#?##?? 1,4,2,3,3 +????#.#???? 1,2,1 +??????????#?##??? 6,7 +?..#?#??#????? 1,1,1,6 +?.???###???#??##.? 1,4,6,1 +????#??.??? 1,3,2 +??###??????? 5,3 +??????..??????.. 2,2,3 +??#??#???? 2,1,1 +?#????#????.? 4,5 +????????????#?? 4,1,2,1,1 +???#.#.??????#?#?#?? 1,1,1,13 +?????????.???#??#? 8,4,2 +?.?.??#????#??. 1,8 +?#?##???#??. 5,2 +.?#??##.??? 5,2 +#???????.????#???#? 2,1,3,6,2 +??#??#?#?????.?? 8,1,2 +#.????#?.???????#? 1,6,4,1,1 +?#.##?###? 1,7 +????????#?????#??? 5,4,2 +#????#..??. 2,1,1 +?????#?#??. 1,5 +??????#??#? 3,3,2 +#??##?#???..???? 1,2,4,2 +?#.?#.?##??? 1,1,5 +.??.?#???#?...? 1,6 +???#???#???#.??##??? 1,3,1,1,3,1 +???.#?#???#?????? 1,7,3 +??.???????#??#?# 1,1,3,1,1 +?#.?###??#.?#??? 2,4,1,1,1 +##????#.??.??.#?.?? 5,1,1,1,1,1 +????#?##??..### 8,3 +.??#?.#????..????# 4,1,1,3,1 +???##?????##???? 5,1,3,1 +??#?#???#???.?.?#.? 11,1 +??.????#.?.#??# 1,1,3,1,4 +?#?.?##???????# 2,5,5 +?#.##??##?..???? 1,7,2 +??#??.?##??.???.?# 3,5,3,2 +??#?????##?#. 4,5 +.????.??.?.#??? 2,2,1,1,1 +??#??.???? 1,3,1 +?????????????#. 5,1,1,1 +???#.???.? 1,1,2 +#???????.????? 8,4 +..?#?.?#.? 1,1,1 +????...????#??# 1,1,1,3,1 +??#??#????#? 5,3 +?.??.???##? 1,1,3 +?????????????. 5,3 +?.##???????.##??? 6,1,2,1 +?#?????.##?.?#?#?? 2,1,2,4 +????.?#?##???.?? 1,1,5,1,1 +?#?????#.?.? 3,3,1 +???#??#.?#???#?? 1,5,1,1,1 +?#??#??.???# 1,3,1,1 +??????##??#??????? 1,6,2,5 +?#?#????#??.?????? 11,1 +.?#??..?#? 2,1 +.?????#?.??## 1,3,4 +???#???#.?#.# 4,1,1,1 +??#?.?????? 3,2,2 +?????.#?#? 2,1,2 +.???#?.????#???.?. 4,8 +???###???#..?#??. 1,6,1,2,1 +????..??#???????? 2,5,2 +???.?????#?#?#?.? 2,1,5 +.????##.?.????.??? 2,2 +??.?#.#??..?#?#?. 1,1,2,5 +?...?#?###?..?##???. 5,5 +?????.#?#? 1,3 +??##???.?????... 5,4 +???##????. 4,1 +.????..??#.? 4,2 +.??#?.?.?##?##???#?# 2,12 +.????#??????..#.???# 11,1,2 +??????.#?# 3,3 +.#?????.??? 1,4,1 +??????#????????????? 10,6 +???#??##???#?? 6,1 +??#???...#.???? 4,1,1 +?????#??..?????#?? 5,3 +?##??##?##?. 3,7 +.??.??.???.?.?.? 2,1 +??.?#????..???#???? 1,4,7 +.????#??????##?#?# 1,1,1,7,1 +???????.?????#????# 6,8,1 +?####????.?? 9,1 +??????????##??#.???# 2,10,1,1,1 +??????....#?.???? 3,2 +...???.????.???##.. 2,3,3 +.???#??#?..??????# 6,3,3 +#.?????##????#? 1,1,4,4 +?..?#?##??#?#??.?# 1,12,2 +?.?#?????..????????. 7,6 +??????#?#????#??#.?? 1,13 +??#????.?? 2,1,1 +??????????#??#?##.? 3,8 +##??????#?.? 6,2,1 +#.????###????????##? 1,1,13 +??#???#?????. 1,8,1 +#.#?????#???##????.# 1,3,9,1,1 +?????#?#??#?????# 1,1,12 +??###??????#?? 5,1 +?????##??.#?.# 1,6,1,1 +?###???#??##?.? 5,6 +?.?????#?#.???????.. 1,2,2,1,4,1 +?#.??#??????.#? 2,4,1,1,1 +.???##?#?????? 6,3 +??????????? 6,1,1 +?.?????##?#???#???.? 1,1,1,2,8,1 +????#.?#.?#???.?? 3,1,1,4,1 +#..##?.???#?#??. 1,2,1,4 +#???#??.#??????.?? 2,2,3,1,2 +?????##??? 4,1 +?.?.???#?. 1,1,1 +??????????.????????? 1,6,1,3,2 +.??????##?????#?# 2,4,5 +.#????#???#?##..? 3,2,5 +??????##?. 3,2 +?.??.????#?#?#?.??? 1,1,4,1,1,1 +#????.??##???????## 1,1,1,6,1,3 +???#????.???#.?.??? 6,1,1,1,1,1 +??.?.#.?.?#? 1,1,1,1 +?????#..????#?#?#?? 2,1,7,1 +???????#... 2,1,1 +?????????????# 1,4,2 +#???#????? 2,5 +.???#???.?##??#?#.? 3,3,3 +.?#????.?.###?. 5,4 +.?#.??##?????.??#? 2,4,3,4 +?????.#?##?????#??? 2,2,6,1,1,1 +.????????.?#??# 6,2,2 +?????#??#?#????## 1,10,2 +.?????.???????#??? 1,1,2,1,1,4 +???#?#?#..??? 8,1 +??##??????..?. 4,1 +..#????..?#?.. 4,2 +?????#.???.?.?.???# 1,3,1,1,4 +#??..????#?? 2,2,1 +?#??.????##??????.. 1,1,1,1,6 +.#?.???.??.?##??#? 1,1,1,1,3,1 +.???#?###.???#?????? 2,1,3,1,6 +##?#..?.??#?????.??# 2,1,1,2,2,3 +#?#???.#?.#?..#?? 3,1,2,1,3 +????#???.? 2,3 +.??#?????.??????. 6,2,1 +?#?#??#??#???.? 4,1,3 +?#???.??????.#??#? 4,2,4 +?#?#.?#??#??#.??..? 1,1,1,5,1,1 +#?????#????#?#?? 4,3,1,3 +????##????.??#?. 3,4 +???.???##??.??..? 3,6,2,1 +?.??????????##???? 1,5,5,1 +?#?#?..?????? 3,4 +?.???#?....????#. 2,3 +?.??????????#??? 1,1,2,5 +?#???##.??#?.?#???.# 2,3,3,5,1 +#..????.##.#? 1,2,2,1 +???.?#????? 4,1 +?#?.??..??#? 2,1,2 +?#?.???.?#?#?#.? 2,2,6 +???..???#??.# 2,1,2,1 +.#?.?.#??? 2,3 +???###?#??#? 1,8 +?##??##?????.??? 6,2,3 +.??#??#??.???????. 6,5 +??.???##?.?????#.. 2,1 +???#?..?#?#..? 2,3 +?.?.???#?..? 1,2 +?#????????????###? 10,5 +?????????. 2,2 +?#??##??##???? 3,7,1 +.?##???##.???.?. 2,3,3,1 +??.?#??.???.?. 3,1 +?#????#??#? 3,2,2 +??#??.????#?#?. 3,1,6 +?##?#..???? 2,1,1 +??.##?..????. 1,2,1,1 +?.?????#.?????#??.? 1,2,2,6,1 +?###.??.?? 3,1 +?.#?#?#.????##? 5,7 +?#??.???#?#.??#..? 4,3,1,1,1,1 +?????#????#????## 1,2,8 +??###?#????#???.#?.# 1,5,5,1,1,1 +.?#?#????#???#.??#?? 12,3 +????#?##??????###?.? 1,6,5,1 +.#.????????#?????? 1,5,3 +???...????#.? 2,2,1,1 +#????####?????#??? 1,1,5,1,1,1 +#????#????. 6,1,1 +.?#??.???.?# 3,2,2 +#???.?#?..?.? 4,3,1,1 +.#??##?#???? 5,1,1 +???##?..#??##?#. 4,7 +??#???##?????? 9,2 +#????.??#. 3,2 +?.????#?#???#? 1,1,9 +?#?#????#???#??? 6,1,4 +??#.??.?#?#???????. 2,2,1,8 +??.??.??..? 2,1,1 +?#..#?##?..#?.#?#.?. 2,4,1,3,1 +??#?????????#?? 5,8 +?.????#???? 1,3,1 +.????#??#?.?#####.?? 6,5 +?##??????.??. 2,1,1,1 +???###???..??? 6,2 +?????.???..#?.? 1,1,2,1,1 +??..#????? 3,1 +???????.?.. 1,2,1 +?.#...#??????#?.??? 1,1,8,1 +.??####?#?????#?.? 10,1 +?#?#.?#.##?? 4,1,4 +???..??????? 1,1,5 +.?#???.?.???? 3,1,2 +.#?#??..?????. 5,1 +?.??#??#???????? 9,1 +.#..???.??.??#? 1,2,1,1,1 +?#???#??#??????? 2,5,2,1 +???#???.??#??##? 1,2,1,6 +??????#???#???#?? 1,1,5,4 +????.##.?#?.?.## 1,2,1,1,2 +??#??..??? 2,1 +.#?.#????? 1,4 +?????.?.#?? 3,3 +#????#?????..? 3,2,1 +?????.?#?#??.??? 1,1,1,3,1 +??#????.#.??#? 4,1,1,2 +?#???..???????????? 1,1,1,1,1,3 +??.???????#??????## 10,4 +?????###????#?... 5,2 +?.????#????#???# 1,10 +.#??.?###?##????#?# 1,1,10,1,1 +?????#???????????#?? 2,13 +??.#?#??.?#????????? 1,1,1,1,11 +#???#.?????.??? 1,1,1,2,1 +?.??#?????????? 1,1,8 +..??#?##???#??????. 6,2,2 +???????.?.????### 1,1,6 +.??#???#.???? 6,1 +.??#.????#??#??????? 1,9,2 +?#????????#.?. 5,4 +????????##??. 2,4,1 +?????.#????????. 1,2,1,2,2 +??????.????#... 1,4 +?.?####????.??##??? 7,6 +.????#####..?????#?# 8,5,1 +##???.???#? 4,2 +??????#????? 1,4 +??##?..??. 4,1 +.??.##?.????? 1,2,1 +????.#???##.?.? 1,6 +?.?#???.??#??.??# 1,3,1,4,3 +???#??????. 3,2 +##??.?????# 2,1,2 +?.??????.????????? 1,3,2,6 +.??????????.???..?.? 6,1 +#??????#?#?????? 1,1,6,4 +#?.?#?.???? 1,2,1 +???.????#?##?#??# 3,1,10 +???????#?????#??. 4,3 +.???##?#??? 5,2 +..????#????## 1,2,4 +??.???.??? 1,1,1 +#?#??##??#???#?? 10,3 +??#?#???#.? 4,2 +???#??#?????##?? 6,4 +?.????#?#??#??.???.? 11,2 +##???????? 3,1 +????#?.?#??????????# 2,2,2,1,1,4 +?..??###?#????#?. 1,1,3,1,5 +?#?#??##??#??.?.#?.? 2,5,3,1,2,1 +.???.?.?.#? 2,1,1 +#?##??#???????????# 12,3,1 +?..?.??#???#?.?? 1,8,1 +.?.?#.????????? 1,5 +??.??.?#?? 1,2 +??????##??#?.? 1,8,1 +?.?.???.??? 1,1,2 +???#?????.#?. 1,5,1 +????##?..??.?? 7,2,1 +???????##? 3,3 +??????#???? 2,7 +????????????..? 7,1,1 +#.??????????#?? 1,3,2,1 +.???#??#?##???????.? 9,1 +????????###??.????.? 13,4 +?????.#????## 1,1,3 +#??##?#?#?.????# 10,2,1 +?.????#???? 1,5,1 +.?#?????#? 3,2 +???##.?.?? 1,2,2 +..?????.???.?#????? 3,1,1 +???#?.???#??.?#??#?# 3,4,6 +?#????.????##?#?? 4,3,5 +?#?#???###?.?..?? 10,1 +.???.??##??##?? 1,9 +?????#.???#? 5,3 +?##?????##?? 2,1,5 +.??..???#?#???.???.? 1,6,2,1,1 +??#??##??#?#?? 7,1,1 +#?????.?##? 2,1,3 +???.#???.#?##?.#?#? 3,1,1,3,3 +??#??#.???.???#?? 4,2,5 +???.?#???? 1,3 +??#?#?.??????# 5,5,1 +???.?????? 2,2 +?.?????.?.??? 1,2,1,1 +????????????????.?.? 1,8,1,1,1,1 +#.???????##?.?.? 1,1,5 +?#???????? 5,3 +??#?.#????? 1,2,1 +.??.##??.???#??. 1,3,6 +???????.#??? 3,1,1,2 +??#?#?.??.#?.? 4,1,2 +??#???#??###..???. 1,1,8,1 +?.??#??.#?? 4,3 +.?.???#???#? 1,9 +?#?.???..? 3,1 +##??#???????.# 7,1,1,1 +???.?#?..?.?????? 1,1 +.#.??##?#???????? 1,6,1,1,1 +?#???##?#???? 1,9 +#??..??###?.??? 1,5,1 +????????##????#? 10,3 +#???#???##?? 1,3,1,3 +?.??????..???????. 6,3 +???#???#???.??# 8,3 +??#?.??.??.??????#? 3,1,2,2,2 +.????????.?#?????? 1,2,1,1,2,2 +.?#?????#..???# 4,2,2,1 +.???#?#??#?#??.#? 1,9,1 +????#?????# 2,2,2 +???#???##? 3,3 +?.?#..?????#???. 1,1 +??????#????# 1,1,5,1 +#???.??#??##?????##? 1,2,6,7 +?.???#????.?? 2,2 +#.???#?#???#???#???. 1,15 +???????.?#.????????? 2,2,2,1,1,5 +??.?#???##????..? 1,11,1 +??#?##??.#?????. 6,1,1,1 +?#??#.??#? 1,1,1 +??##????.?????? 5,1,1,1,1 +??????????????? 6,1,1 +.???##??.?#??# 5,1,1 +????.??.#? 1,1,1 +..#.?#?#?##??##??#? 1,13 +?.???##??.???#.?# 1,7,1,1,1 +?.????.??#?##?#?##.? 1,1,1,11,1 +???????????? 1,6 +????.?????#??#???# 1,2,1,5,1,1 +?.??##???##.# 9,1 +??.???#???????? 1,1,1,3,1 +.??.?.????##?##..? 1,6 +?#??.#?????. 2,3,1 +???..#??.???.???? 3,1,3 +..????#???#??? 7,1 +?#????.?????.#?? 4,5,2 +??#??????? 6,1 +??????.#.#? 6,1,1 +??.?..?##? 1,1,4 +??#?.?#?.?#? 1,2,1 +.?#.???????#? 2,2,6 +??.?????..????#???# 2,9 +???##?#.??#??? 2,2,1,5 +???#??????#?????. 3,6 +?.??????#?.?.???? 3,3,1 +??.????.?#? 4,2 +?????????.??.??? 6,2 +?#..???..??#?..?. 1,2,2,1 +?...???##????.??.??? 8,1 +????#???#?#?????.# 5,1,1,3,1 +??#??#??#??.????? 11,1,1 +??#??#?#?#? 2,7 +??#???????.?#??????? 1,1,1,2,7,1 +?##??.????#??#?##? 4,10 +?#????#.??.? 2,1,1,1 +???#??.??.????.??.? 1,3,2,4,2 +????#????.?.?# 4,1,2 +?#?##????#.?#.??#?#? 10,1,1,1,1 +???#?.??????.?? 5,2 +?????????#??#? 3,5 +.??.#??.??? 1,1 +?####??#.#.#?.? 4,1,1,1,1 +#?#??.??????. 5,3 +.?#???.?.?. 4,1 +..??.?#???...??#?..? 1,3 +.???...???#?#?###?? 3,11 +???.????#??#.???.? 1,1,5,1,2,1 +??????.?..?? 1,2,1,1 +??.????#?.??.#?.? 1,2,2,1,2 +??#?#?????. 3,4 +?#?#??#?????.. 6,3 +???#??#??#????? 1,1,2,1,1 +?#.??.??#???#??? 1,7,1 +?.???#?#???? 3,4 +???#???.????##.? 1,6 +?###?#??.##????? 4,2,2,2,1 +.?.??????????.# 4,3,1 +????#??#???#???. 2,4,4 +????.?#??? 2,4 +??.?#????##???????. 1,15 +?#???.??.?#????.#. 2,2,1,5,1 +??????.?????# 5,1,1 +??.?#.???#?. 1,2,1,2 +..#?#???.??.? 6,1 +.?#??...?#???? 4,3 +?#..???#?... 2,5 +#.?#??#????????????? 1,12,4 +?.#..?.#.?###? 1,1,1,4 +?#??##??.. 1,4 +??##?#????#??#?. 5,7 +??##??#?#?????.?.## 11,1,1,2 +???##?.???. 2,3,2 +?#?????#???#.##?# 2,6,1,4 +????.#?#????#?? 1,2,1,4,1 +#.??..?????????? 1,1,7 +?.#?.?#.?????#?. 1,2,1,2,1 +??????###?.? 1,5 +??#???#???????? 10,1 +.??#??????#?. 5,1 +???#.??#?.?# 1,2,4,1 +??.#???#??#?? 1,6,3 +?#?#.????? 4,1,2 +??##??...???# 6,1,1 +???#??????. 3,1,1 +?????#?#??##????. 7,2,1 +???.?#??????#??#??. 1,3,3,4,1 +.??????????.?????.?? 7,1,2,2 +?##?..??#?.??.????#? 4,2,1,5 +??##?????# 5,1,1 +?..??????? 1,2,1 +.??.#??.???# 1,1,1,1 +????.#?????..?.?# 1,4,1,1,1 +##???#..?# 6,2 +??????.???? 1,1,2 +?.#??###?#? 6,1 +.???#???.???? 4,2 +???#???.??###?#? 1,1,1,7 +?#??#??.#?#??####? 2,1,9 +.#??#????.?# 1,1,3,2 +.???.?.???#????. 1,7 +????????..#.???. 3,1,1,1,1 +????##??##??? 1,6,2 +?.???#????? 1,5,1 +???.??#??.?.? 3,2,1,1 +.??..??#??.?. 1,4,1 +.#??.???????#??#?#? 1,1,10 +?.??#????.?#. 6,2 +????.?#??#??#??.???? 2,8,3 +.????#???#.????? 9,1 +??.????##.?#.??? 1,2,3,1,1 +.#.??#????#????##.## 1,1,9,2,2 +????#..?#? 3,1 +????##.#.?##.???..? 3,2,1,3,3,1 +?#.#?#..??? 1,3,1 +##???#?????????##?. 8,1,6 +???...#??#? 1,4 +.??.?????#?#?????? 1,1,10 +?.??????#?##??. 2,2,4 +..??#?????? 3,1,1 +??####????????.?? 7,1,1,1,1 +????#?##??.????..?. 6,1 +???#?#???.?# 6,2,1 +????#?????#.?.?##. 1,5,1,3 +?.#???.??????#. 4,3,1 +?.???#??.????#. 4,5 +?#?##?#??. 4,1,1 +?#??##?????.?##? 7,2,4 +?#??##?????????##? 2,6,2,3 +.#?#?#?##??? 3,6 +.##?.????.. 2,3 +????????????????# 4,1,1,4,2 +?????#????.????## 1,5,1,4 +?.#..?#?###??#? 1,8 +?????##??????.??? 1,11,2 +.?#??#?????.? 8,1,1 +?????#??????#?## 7,7 +?..##??#?#?? 1,2,1,3 +???????#.. 4,1 +??.???..?????? 1,1,4 +????#???#??#? 5,1,1,2 +????#?????.????#? 8,1,1 +????.?.????. 3,1,3 +.?####?.??????????.? 4,9 +#.?#?##??????. 1,4,3 +#.?###?#??????..##?? 1,5,2,1,4 +.?#.??????#.? 2,1,2,1 +#.?.????#?? 1,1,5 +?#???.?#??#? 2,1,4 +?????#?#?? 2,3 +??#.###???.???? 2,3,1,2 +.???..#???. 1,1,1 +?.?#???#??.?#. 1,1,5,1 +???#???.????#??#?#?? 6,11 +???#???????? 3,6 +#.?.??????#?????#?? 1,1,5,5 +??#?#???..??? 7,1,1 +?#?#??#?##??????? 3,12 +..?????.??????.?#? 4,1,3,2 +?#?.#..#?#????#???#. 2,1,1,1,6 +?.?.##???.?? 2,2 +?.???##????###??? 1,7,6 +????????##???? 1,3,3,1 +.??...?#?..??#?#?? 1,5 +?.#??#??.???.#??? 6,1,1,3 +?.??#?????# 1,3,1 +.????????#?#??#???? 1,1,1,8,1 +????????.?#?? 2,2,1,1 +..????????.?. 1,1,2,1 +??.#.?????? 1,1,3 +..?#?????####???. 1,10 +?#???####????# 1,9,1 +???##?#????#???? 1,10,1 +?????#????#???.# 1,3,1,2,1 +.#????#???.#??.?. 6,1,3 +???????.????????.?? 1,4,4,1,2 +?.??.#?????#. 1,3,2 +.##???#?#?#?..???.. 10,2 +#??..?????#?.?.?? 1,1,6,1,1 +?##?##??#?? 5,1,1 +???????... 2,1 +#????????? 1,1,2 +???.??#??#?#? 1,9 +.??#?.?#?#??????? 1,9 +.?##?#.?##??.?##? 3,1,4,4 +?..#?????.? 1,2 +?.????##?#.? 1,1,5,1 +??#?????????? 3,2,1 +??...?.???#???##.?. 1,6 +??#?????????### 5,2,3 +?#????????#?#? 2,1,2,2 +??????####?????##??. 1,11 +???..???#?.#?? 2,5,2 +???.?????# 2,4,1 +?#?#???#??..#?? 9,2 +#?.??.??????#?#???? 1,2,2,8 +?..??#???.?#???? 3,1,2 +##?#?.##???# 4,6 +??##?.????##???.. 4,6,1 +????.????? 3,3,1 +???????..?? 1,2,1 +??????.???#?.#?.??. 4,4,1,2 +??.??#??.#? 1,2,1 +?..????#?????? 1,6 +?????#.?..????.#?? 4,1,1,1,1,1 +?.#??.#?###?????##. 1,1,5,3 +.?..#?.?.?#??#???? 1,1,1,5,1 +#??#?#?##????? 6,2,1,1 +??####..#?? 4,3 +?#??##????.?#?? 6,1,3 +??#???#?#?? 3,1,1 +??.##?????? 2,2,1 +???????.?#?#..?#.?? 1,4,2,1,1,2 +???????.#??# 4,1,1 +???.?.###??#???? 1,6,2 +??...?#?#? 1,4 +??.#???#???.??????#? 2,3,2,3 +.?###??.?.?#????. 5,5 +#????##????.?????? 8,1,1,2 +??.??#???? 1,1 +?.?#???.#.? 2,1 +?#.?.??##???.?#? 2,1,2,1,1 +??????...?? 2,1,2 +#???##??#????#?#.?# 14,1,1 +?#?????.?# 1,1,1 +?#?.#.??#???? 2,1,7 +????#??..??? 1,3,1,2 +?.??#?#?.?.?. 1,5,1 +?..??#?#??.?#.#?..# 1,4,1,1,1,1 +.?#????.????. 1,3,1,1 +.#???.?.#??#???.#?# 3,4,1,3 +??..?#??#???##??#?? 1,2,7,3 +????.?##?????.???#. 1,1,5,1,1,1 +?#?????##??.#.?.?.? 6,2,1,1,1 +?#??#????.?#.???#. 8,1,1,2 +#???.##?.?. 1,1,2 +#.#?..?.?#?#.? 1,1,1,3 +???#??.#?#???????? 5,8,2 +?#???#?.??#?.???.. 3,3,2,2 +.##??????.##??? 2,3,5 +?#??#???#?#??##?? 4,1,1,4 +???.??#?#?#?##? 1,10 +????##?###??????? 1,13 +????#?.??#?? 1,1,5 +????##???#???# 1,6,1,1 +.????.?.???????? 1,1,1,1,4 +??????#?.?????? 1,1,3,2 +???.??.??#??##.#. 1,1,1,7,1 +??.?##???# 1,4,1 +?????????. 3,1 +.?????#??. 2,3 +??#??###???.?.?#?#? 8,1,1,5 +?#????.?.??????#???# 1,1,1,7,1,1 +?#.#?##?.##? 1,5,2 +?#???#??#??.?????? 1,2,1,4,1 +??#??#????.##???? 6,4 +.#???????#????? 3,5,2 +.???.???#? 2,1,2 +?#??????##???.# 2,1,6,1 +?????#?#?? 1,4,2 +?..#??#???? 1,4,1 +.#?????#??#??#? 2,4,6 +.#??.?.?????? 1,1,1,2 +.?????##.??.?#??? 1,3,1,4 +?.?#???#??.????.? 5,1 +?#???.##?. 3,3 +?????????#??.?? 4,2,1,1,1 +????..?#?#?#?# 1,2,8 +???????#.????.???? 5,1,1,1,2,1 +??#?.?####??? 2,4,1 +##??.##??#???#.??# 4,5,2,2 +?##?.????##??#???#? 3,2,6,1 +#???.?????????? 1,2,1,7 +#?.?#??##??#??#??. 1,1,10 +??#???????????# 3,1,1,1,2 +.??#???#??#.? 8,1 +?#?????##??. 2,6 +??#??.???..?..# 2,3,1,1 +????.?????#?#?. 1,2,4 +??.???#?.???????#.## 2,2,4,1,1,2 +??#???##.?? 1,1,2 +?#??????.????##?? 5,1,3 +.???#?#??.??. 3,2,1 +?????#???? 1,2,1 +?.?.?#??.??#?#????? 1,2,1,1,3,2 +??.?????.?????##? 1,1,1,1,8 +??#.??.??#?..??? 2,1,1,1,2 +???#??.#?.???#?#?. 4,1,1,1,4 +.?#??.??#?#?###??#.. 2,10 +???.??#..?? 1,3,1 +?##?#.??..#...##???? 4,1,1,6 +?????##???#??.#??.. 10,3 +.#.???????? 1,2 +??#.?????? 2,2 +#?????#?.?? 8,1 +????.??##?. 1,3 +#??#?#?????#?.?? 7,1,2,1 +????#?.???#???##???. 1,4,1,9 +?????????#? 1,4 +.??#??#????????#??. 4,3,6 +??#?????#????????.?? 2,2,7,1,1 +#?.??#????.????.. 1,6,1,1 +?????#???? 2,4,1 +....???...????#.? 1,5 +???????..??#?#?? 1,2,3,1,1 +?#?##??#???#???????? 15,1,1 +#???#?????#? 2,3,3 +#????.?????????? 3,1,4,1,1 +?#?????#?? 1,4,1 +??.?#??#?# 1,3 +.??#????.????. 6,3 +?#??##.????????#?#.? 5,1,1,1,3,1 +??????????.#?#? 5,3 +.??????#?..? 1,1,1,1 +????#?????#????##??. 1,14 +????.??.??#?? 1,1,1,4 +##?#???#.???.?. 6,1,1,1,1 +.???..???###??? 1,1,9 +??.?#????#???. 2,5 +.???.??###? 1,4 +??#???#?..#?????#?? 7,1,1,5 +?????#.??#? 5,2 +??.??#.#????#?????? 2,3,1,9 +??##?#???.?? 1,7,1 +??.????##?? 2,2 +?.??.#?#??????????? 1,2,3,2,1,4 +?#???.?????. 1,1,1,2 +.?#??????? 4,1 +??#?#?.???????????.? 5,1,1,1,1,1 +??#?.???#???.?? 3,6 +???????###?????# 4,5,1,1 +???.??.??.??#???##? 1,1,1,1,2,3 +??#?#????##.???#?. 5,2,2,1 +?.???.??#??#.?#? 1,3,1,2 +?#.?????#. 1,1,2 +?.????#???????#???? 1,4,10 +??.?????##?. 1,1,6 +??.#.##?????#???##? 2,1,10,2 +??.?????.#???.#??? 1,1,1,1,1,3 +???#??##.????? 7,1 +?????????????#?##? 3,7 +?#?????##?#???? 5,6,1 +????##????#???#?# 7,8 +.?.???#???.#???? 1,6,1,1 +??.#?.?.?.?? 2,1,1 +???????..??? 2,2,1,1 +??#???.????#. 3,2,1 +?.?????????.??????.? 1,9,1,1,1,1 +.?.?????.???..??? 3,1 +?#.?.?##????##?.. 2,8 +#.?????##????#?#.. 1,7,3 +?#?????.??##??#.??? 5,6 +??????.????????. 2,1,1,2,1 +??#?.#?#??#? 3,1,2,1 +##???.?#???.??..#?? 2,2,4,1,2 +#?????##?.?????#?#? 1,1,3,8 +??????.##??? 1,5 +?##??.??.?? 3,2,2 +????#?###?#?.?##??#? 12,3,2 +...?#?..?#?#? 2,4 +??????????.?#.??#?? 8,1,5 +.#????#??##?.?#??? 11,3 +?.##?.????????#??##. 2,9,2 +??#??#?#????##????.# 13,2,1 +.???###??????### 6,5 +.?????##????. 1,4,1 +???????.?##? 3,3 +??#????.?.???????# 1,2,1,6 +???????????##? 4,6 +??#???#?????? 4,1,1,1 +.?##??#.?#?#?##??. 2,1,8 +?#??????#?#???#. 6,3,1 +?????##???????.?#??# 2,2,4,1,1,2 +??.???#.??? 4,1 +.??????????.? 2,1 +????.?.???.#? 3,1,3,1 +.?#?#?###?.## 2,1,4,2 +..???#?????##. 4,3 +?????.?????#?#?? 1,1,1,3,1 +#??##????????????#? 1,3,4,5 +??????#?.?? 2,2,1 +????.?.?????? 3,1,2 +.?????.?#.#??### 1,3,1,1,4 +??.?.??#?. 1,1,2 +.?#??##?.?. 1,3 +?#..??????##?? 2,1,5 +????????#????????. 1,1,2,1,3 +#????###???????#? 3,3,1,4 +?#???????.... 1,4,1 +?????.?.???## 1,1,2 +?????.##?# 2,4 +??????..?? 2,1,1 +#??##?#?....### 1,3,1,3 +.??????.?.#???.??. 5,1,2,1 +##???#??.???#?????? 2,3,1,1,4,1 +???????.?#??? 7,1,1 +?????.?.?#. 4,1,2 +??#?.?.???#?#? 2,1,5 +.?.?#????? 1,4 +??#??.?.??? 3,1 +.#??.###???.?? 1,1,5,1 +??##???#??.??# 4,5,2 +?????#???#? 5,1 diff --git a/2023/tests/day12.txt b/2023/tests/day12.txt index e69de29..e925935 100644 --- a/2023/tests/day12.txt +++ b/2023/tests/day12.txt @@ -0,0 +1,6 @@ +???.### 1,1,3 +.??..??...?##. 1,1,3 +?#?#?#?#?#?#?#? 1,3,1,6 +????.#...#... 4,1,1 +????.######..#####. 1,6,5 +?###???????? 3,2,1