From 13498a215ba236ec8250b75ab2c233efd71316c1 Mon Sep 17 00:00:00 2001 From: narimiran Date: Tue, 12 Dec 2023 20:09:14 +0100 Subject: [PATCH] day12.clj --- README.md | 2 +- clojure/day12.clj | 55 ++ clojure/tests/solutions_tests.clj | 3 +- inputs/12.txt | 1000 +++++++++++++++++++++++++++++ inputs/12_test.txt | 6 + 5 files changed, 1064 insertions(+), 2 deletions(-) create mode 100644 clojure/day12.clj create mode 100644 inputs/12.txt create mode 100644 inputs/12_test.txt diff --git a/README.md b/README.md index 5026326..23b70e1 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ Day 00: Helper file | [aoc.clj](clojure/aoc.clj) | [Day 09](http://adventofcode.com/2023/day/9) | [day09.clj](clojure/day09.clj) | .esreveR [Day 10](http://adventofcode.com/2023/day/10) | [day10.clj](clojure/day10.clj) | No BFS needed. [Day 11](http://adventofcode.com/2023/day/11) | [day11.clj](clojure/day11.clj) | Off-by-one trap! - +[Day 12](http://adventofcode.com/2023/day/12) | [day12.clj](clojure/day12.clj) | Immutability, meet my friend `atom`. diff --git a/clojure/day12.clj b/clojure/day12.clj new file mode 100644 index 0000000..2322d77 --- /dev/null +++ b/clojure/day12.clj @@ -0,0 +1,55 @@ +(ns day12 + (:require aoc + [clojure.string :as str])) + + +(def cache (atom {})) + +(def is-operational? #{\. \?}) +(def is-damaged? #{\# \?}) + + +(defn parse-line [line] + (let [[pattern groups] (str/split line #" ")] + [pattern (aoc/integers groups)])) + +(defn unfold [[patts groups]] + [(->> patts + (repeat 5) + (interpose "?") + (apply str)) + (->> groups + (repeat 5) + flatten)]) + + +(defn arrangements [[pattern groups :as pg]] + (if-let [res (@cache pg)] + res + (if (empty? groups) + (if (every? is-operational? pattern) 1 0) + (let [[size & tl] groups + post (+ (reduce + tl) (count tl)) + score (atom 0)] + (doseq [pre (range (inc (- (count pattern) post size))) + :let [[before pattern'] (split-at pre pattern) + [current remaining] (split-at size pattern')] + :while (every? is-operational? before) + :when (every? is-damaged? current)] + (cond + (empty? tl) (when (every? is-operational? remaining) + (swap! score inc)) + (is-operational? (first remaining)) + (swap! score + (arrangements [(rest remaining) tl])))) + (swap! cache assoc pg @score) + @score)))) + + +(defn solve [input-file] + (let [lines (aoc/read-input input-file parse-line) + unfolded (map unfold lines)] + [(reduce + (map arrangements lines)) + (reduce + (pmap arrangements unfolded))])) + + +(solve 12) diff --git a/clojure/tests/solutions_tests.clj b/clojure/tests/solutions_tests.clj index 58635de..6fe4109 100644 --- a/clojure/tests/solutions_tests.clj +++ b/clojure/tests/solutions_tests.clj @@ -2,7 +2,7 @@ (:require day01 day02 day03 day04 day05 day06 day07 day08 day09 day10 - day11 ; day12 day13 day14 day15 + day11 day12 ; day13 day14 day15 ; day16 day17 day18 day19 day20 ; day21 day22 day23 day24 day25 [clojure.test :refer [deftest is run-tests successful?]])) @@ -35,6 +35,7 @@ (check-day 9 [114 2] [1581679977 889]) (check-day 10 [70 8] [6864 349]) (check-day 11 [374 82000210] [9724940 569052586852]) +(check-day 12 [21 525152] [7286 25470469710341]) (let [summary (run-tests)] (when-not (successful? summary) diff --git a/inputs/12.txt b/inputs/12.txt new file mode 100644 index 0000000..83c7cd8 --- /dev/null +++ b/inputs/12.txt @@ -0,0 +1,1000 @@ +?..#?.??#?...??##??? 1,2,2,1,5 +?????????#? 1,4,1 +????#?????.???# 1,3,2,4 +#???#???##?? 1,9 +??#???#??? 2,3 +..?.???#.????.???# 1,2,4,1,1 +??.???????#?#.??# 1,3,3,2 +???#?????#?. 5,1 +.???.???????????#?. 2,10 +????#?.??#??. 5,1 +.?.?.????#???????.?. 1,1,1,7,1 +..#???????.?.??? 5,1,1,1,1 +.???#?#?.? 4,2,1 +?????##??#.???##??#? 8,8 +#???..#.?#??# 2,1,2,1 +?#??????.#?#?.?..# 5,1,4,1 +????#.?.?#?? 3,1 +#??????### 1,1,4 +.?..??????? 1,3,3 +#?#??#?#?##??#.?? 3,1,1,5,2 +???#?.????.? 4,1,1 +?#??#..???????.?#?? 2,1,1,1,1,4 +#.##???.#??##????## 1,2,1,1,4,4 +??#?#??.?????#??## 1,1,1,1,5,2 +?#??#????#?#?#? 2,1,1,6 +??#???????#?????? 7,1,1,1 +???..??.?? 1,1 +.??#??????#?????###? 2,8,3 +??.???..#?.??#???? 2,2,1,3 +????.????? 2,1,1 +.#???##??##?#??.? 2,10 +.?#????.#?? 2,2 +?.?#???.#????#????#? 1,5,1,1,3,1 +?###????..#??#? 6,1,5 +?????.##?. 2,2 +??#???????????#?? 1,1,2,4,4 +?#?#??#?#.#?? 1,1,4,1 +#??#?.?????# 2,1,3,1 +?#?##..???#??#..??? 4,7,2 +.????#?????#?.??. 1,8,2 +??###??...#?###??.. 3,6 +???#?#.?.??#?.? 3,4 +?#?????#????#?? 1,9 +???#.??..????.#?##? 1,1,1,2,1,5 +???.?.????.. 3,1,2 +.?????????#.? 4,5,1 +?????.???.?#?? 1,3,2 +?.??..????# 2,1,1 +.?.???.????. 1,1,1,1 +..???#?#??#.?.?#??? 7,3 +#?#.#??#####??? 1,1,1,7 +???????#??#?#???## 1,3,1,6,2 +????????#????#?#?.?? 1,1,1,1,4,2 +??????????????##? 1,2,1,2,4 +??????###.??? 1,7,1 +???#.??#????.? 1,4 +????#?????.?#?#???. 10,5 +.????????##????.?? 1,2,3,2 +?.???.?.#. 1,2,1 +?#?#.????.#. 1,1,1,1 +.#.??????#?.#?? 1,1,2,2,2 +??##??????? 2,1,1 +?????###????#?? 9,2 +????#.??.??###.?. 2,5 +.?#????#.? 2,1 +???#?.?.???? 3,1,1 +.?#??#.??#???#?.?#? 4,8,2 +.?#????????#. 7,3 +.??##.??##..?.#? 4,3,1,1 +.???.#.??????? 3,1,3,1 +.????????#??.#??? 4,2,2,3 +?###?.???#. 4,1,1 +???#?.#???#??. 1,6 +?.??#?.??# 1,2,2 +?##???.#?? 2,1,3 +??#?????#?#?#?? 1,1,1,6,1 +?.?????#???.#?? 1,8,2 +???.#?#??#?.? 2,4,1,1 +?#????#???.??#??? 8,3,1 +?.?..???????? 1,1,1,2 +??#?#????#????#?? 1,1,6,5 +?#?#?#???#.???#? 6,2,1,1 +??#.?#.???#?.##?#? 1,1,1,3,5 +#??.#?????? 2,2,1 +????????#??. 2,1,2 +?#?????#?#??.? 3,4 +????#????#????#???? 1,14 +.#?#??##??.#.??? 3,5,1,2 +#??#???.???#?#? 7,2,1,1 +##..#??????? 2,2,4 +?#????.?????#??? 4,5 +#???.????#???? 1,1,8 +???.?#?.#??..?? 1,2,1,1,1 +??#??#???.?????##?.? 8,4 +??????..?? 2,1 +???.??.#???#..?# 2,3,1,2 +?#??..????.. 3,4 +..#???.???? 3,2 +???..????.??. 1,4 +?????????.#???#? 7,1,3 +?#?#???.??.. 3,1,2 +.?????.?????#?#??# 1,3,11 +#??###.?#???#? 6,1,1,2 +??????.?#? 2,2,1 +?????#?#??..? 3,1,1,1 +????????????#?.?. 2,7 +???.?.??????#??#? 1,10 +??????????. 2,3 +???##??#??. 1,8 +???.?#???? 1,4 +.???###..#?#?#? 6,3,2 +??..??????. 2,5 +#?????#??#???.#?.#? 2,3,3,2,1 +.???#?????# 1,4,1 +??##.??????.????? 4,1,1,1,1 +.????????#?? 5,2 +?.?????????#??????#? 1,6,1,1,3,1 +?.???#?.????? 1,4,1,1 +????????#?? 2,2 +.??#???#???. 2,3 +???...??#?#??????#? 1,6,1,2 +??.????????? 2,3,1 +?.#.??#?????#? 1,1,7 +##??#??.???#??.?? 2,4,5,2 +.#??????#?..?.??#?## 1,1,2,6 +.??????????? 2,6 +#????.??????? 3,3 +?#??#?#.?#??.?#?? 2,3,3,1 +???#?#?????#?.???.. 12,3 +#.???##??..???.# 1,6,1,1 +?#?###???#??????. 7,4,1 +?.????????#??.#?? 1,3,4,2 +???????????.. 3,2,1 +?.?.?##?.? 1,1,2 +.#.#?.???..??###. 1,2,3,4 +?#?.??????.#?#???.# 1,2,1,6,1 +.???.?????#?? 1,1,2,2 +?????.#????#.# 3,1,3,1 +?#???#?#?#??.?#??# 10,5 +???..???.?????#? 1,3,1,1,1 +???.#??#?#?????#??? 2,4,9 +?????..???#?.#? 1,2,1,1,1 +..???.#??#???? 2,1,3 +???.?#?????. 1,1,1,1 +????.???#???????? 1,1,1,4,5 +?..?..??????# 1,1,7 +??.?.?.###?. 1,3 +????.?.?#???#????.#? 1,1,2,4,1,1 +?????#??#????#?.#.# 3,4,1,2,1,1 +????#??.???.???? 3,3,1,1 +?.???##??.?#? 4,2 +???.?..???.?#??#? 1,1,1,1,5 +#???????.??#?##.??? 6,6,2 +#????#??.??. 2,3 +??????#??.?.?? 1,3,1,1 +??????.???##??.? 1,4 +??#????#??#??? 4,4,1,1 +.#??.?#??????.?? 3,8 +?#?..???##???#??. 2,6,2 +??##?.???#??# 4,1,2,2 +??????.?.?. 1,2,1 +?.?????????.????#? 1,2,4,3 +?????#????#?.?? 1,7,2 +??#??????? 2,3 +#??#?##??##??.?#???? 12,2,2 +??#??#??#??##??????. 2,4,2,5 +#??#?.?#??? 5,2 +####??????????? 5,4 +##.??#.?#?????? 2,2,3,2 +##?????.??#?.?? 2,1,1,3,1 +?.??##?##? 1,7 +?.???.?#?##?#?#??? 3,7,4 +??????..?#?????????. 5,4,1,2 +?.??##?#??#??? 2,4 +?.??????##?.#??#.? 1,2,1,3,2,1 +#?.???#?#????# 2,4,1,3 +#####???#???.??.??. 9,1,2,1 +.#??#?#??????? 7,1 +?????????#??# 2,2,1,2 +?#?.?#?#????#????# 2,4,1,1,2,1 +???????#??###? 2,10 +??.?.?????#????.#.#? 2,1,4,5,1,1 +????..#?.?#? 1,1,1,2 +???.?????? 1,3 +#???#?????#? 1,9 +????????##???? 1,1,5,2 +??.?#.?#?#??? 1,2,7 +.?.?#?????????.? 8,1 +????????.?????? 3,1 +?????.??##? 2,1,5 +##?????#????? 3,6,1 +?#?#?..?.?##? 2,1,1,2 +??????????#??..#? 12,1 +?????#??#?.??#?.? 6,2,3 +?.?.#??.?. 1,1 +.?#??.???.#. 3,1,1 +?.?#.????. 2,2 +??#?##???. 1,6 +..????#.?.?#? 5,1 +?###?????????.#?. 4,1,3,2 +???.?????#? 3,1,3 +???###???#.??#? 9,2 +?.??#???.??? 1,1,1,3 +?#??????##??.#?#???# 5,5,3,3 +#???#??.?#??###? 1,2,7 +.?#?#???.?.??.?.##?? 7,1,1,1,3 +??..#?.????. 2,1,1,2 +??..?.??#?????.?? 4,1 +????#?#?.#??? 7,1,2 +.??????????#?? 1,9 +??#..?????#.#.????? 3,2,2,1,1,1 +??.##..??? 1,2,1 +#..???????.##????#? 1,1,1,3,3,3 +##.??#?????#??? 2,1,1,1,1 +.###???##?????? 4,5,1 +#.?##?????????# 1,4,1,1,3 +?###.?.???#?????. 3,4 +?#?????#???#. 2,1,2,1 +.?.???????#? 1,1,2,4 +.???????#?????. 2,4 +.#..?.#??#??.? 1,2,3 +?.?#??.?.? 1,1 +?.???????#?? 4,3 +.???????#? 2,5 +????.??#?# 1,1,1 +??.?????????## 2,4,1,2 +#???#.???.????# 1,1,1,1,4 +?#??????.?.#.??.???? 7,1,1,1,1,2 +.?##?#???#?###.?? 13,1 +?.##??##?.?? 6,1 +.?????.??.????##?? 1,2,5 +???#???##.? 1,6 +???#??##?#?#?.? 2,1,7,1 +?..????##?#?## 1,2,8 +.?????###?..?..???? 6,2 +#...????..???. 1,4,3 +#?#?????..?.? 6,1 +????#??##??#? 2,2,6 +??#????#???##??????. 16,1 +???###?.??##?? 6,1,3 +?????????..#? 2,2,1,2 +???????.???? 2,1,1,2 +???????..?#?? 1,2,2 +??????##?#?????#? 3,5,1,1 +.?.??#??????#?.?? 3,2 +??????.?#???? 1,1,1,6 +????.##?#?## 2,7 +.#?????##? 1,2 +.??.#??.????### 2,1,4 +????..#??.?????#?? 1,1,1,1,3,4 +.????#?..#? 5,1 +#????.???? 2,1,4 +?##.??.?##?#??.? 2,2,7,1 +#??#???#??#??## 1,6,5 +???.?.?#?#???? 1,5,1 +#?.?#?..?.#????# 2,1,1,4,1 +????#..#?#??#????? 4,9 +???#?#????#????.? 1,4,1,5,1 +?.?????.#???? 3,4 +?????#.????#??.?? 2,2,1,5,1 +?????#??.#????.??. 7,1,1,1 +??.?.????#?.??#??.? 3,2 +??#?###??.#?? 6,2 +?##????..#.??. 3,1,1,2 +.?????##?#??#???#.? 8,5 +#??#???###?.. 1,3,5 +??????????#?????#. 11,1,2 +###?#?#??..??? 7,1,1,1 +#??#??#?#???..### 1,1,4,2,3 +#?.????????.? 2,2 +???.?????.???#.? 1,1,4,4,1 +?#.?????##???? 2,2,2,1 +??.#????#?????.?.. 1,1,8,1 +????.?.???????. 1,1,1,2,1 +.???????#????.???. 9,2 +???#???#???????? 1,4,1,1,1 +#??##.??## 2,2,3 +?#??????.#??#??? 2,3,1,2,1 +.????.??#??????..? 1,9 +?.#?#?#??...???? 5,3 +..?#????#?.???? 8,2 +.#??#??.##??#??????? 4,1,5,2,2 +#?.??#???#??? 1,10 +?.#?????????? 5,4 +?????????.? 2,4 +#???.?#?#????.?### 1,2,6,4 +#.??#?###??.?#??# 1,8,5 +.?.???#??#??#??#???? 1,13 +?#?#??#??#?????.??? 3,1,7,1 +.?#.?#.?#??.? 1,2,4 +????#.?#.???? 1,1,2,3 +?????#.?#?????.?. 1,1,6,1 +????.??????###... 2,2,5 +??.?#?#.????. 1,3,1,1 +???#.#??.? 1,1,2 +???.?????????.??? 1,5,1,2 +???????????.? 1,3 +?????#????? 1,2,1 +?.###????..??..? 1,3,1,1 +???#.??#??? 1,1,3 +?.?#??##?.?## 1,6,3 +?????#?#?????.?? 2,8,2 +??#.?#?.#..# 1,1,1,1 +???#?#??#.????##?#? 8,8 +.##?.?????.?. 2,2 +??????????##?#??. 2,8 +?##?.????????? 2,4,1 +?#?#.??.??. 3,1,1 +#..???.#?? 1,1,1 +#.?#??#??#???#?#.?.. 1,13,1 +#?????.?#??? 5,3 +?#??#??#???#.#?? 1,6,1,1,1 +#???..??????..?? 4,1,1,1,1 +.#?#.?????????#?.??? 1,1,5,5,1 +..##?#.#?????. 2,1,2,2 +#??.?.#?#?##?????. 2,1,7,1 +#???#??????? 1,5 +?.??#??#?.?..??.? 1,5,1,1,1 +???#??.?.??????#???. 1,4,1,1,6,1 +???#????.?.?.?#?. 1,5,1,1,3 +..???#??.#?# 1,1,1,1 +.?###.?.?.#?#.#?? 4,1,3,3 +???.?.??.????#.? 2,1,1,2,1 +???.?.???? 2,2 +????#?.?????#??.?##? 1,2,5,4 +..?????.#. 1,1,1 +?.???.????? 3,1,1 +???????..????#.???.? 2,1,1,3,1,1 +???.?..???#??#??? 1,1,8 +?????????.???.????.? 1,2,2,2,1,1 +.????.##?.. 1,2 +#?????????.??#???# 7,1,1,1,1 +?.?##..###???? 1,2,3,1 +.????#???#?#.??. 1,2,1,3,1 +??#.#????????? 2,1,3,3 +???.?..?#...?? 1,2 +??..??#??###??#?#??? 2,7,7 +?????#???..#. 2,5,1 +#???.???.?#????#??? 2,1,4,4 +??.##?????? 1,2,1 +?????.????..???#?. 2,2 +?????.???#?#???? 1,2,6,2 +?????..??.?. 1,1,1 +?.????.??? 1,1,1 +?????????????? 1,1,1,6 +???#?????.??#? 5,1,1 +??#??.#?#?##?#???#?? 2,1,6,1,1,2 +???????.??.?.?#?.?? 5,2,3 +?????#?????.??? 9,1,1 +.???##??.#?? 6,3 +???.?.??## 2,3 +?.???#?##??.???? 1,1,1,3,1 +????.?####???#??## 2,13 +??????????? 8,1 +#?.?##???#??#??? 1,10 +???#???##?????????.? 11,1,1 +.#?.??????# 1,3,2 +#?#?.#??.?.#.??.#?# 3,1,1,1,1,3 +?.???#?.??##?????? 1,2,2,3,1 +??#??#???.#.??? 3,1,1,1,1 +#?######???????# 11,1 +#???#???#?????.#.#? 12,1,2 +??#?#.????#?##?#??? 1,1,1,10 +?.??#?.??.? 1,3,2 +.?#??#?#?#??.?????? 9,5 +?#??#????????#?.??#? 2,12,1 +???#???????#?##? 3,3,4 +#?#????.????#??# 4,1,1,5 +???##?##????#.???? 8,2,2 +?????????.#?.###..? 1,7,1,3,1 +.#?????.?#?? 6,1 +#???#?#??#? 8,1 +????#?.#.. 1,1,1 +?#??#?#?.?????#? 1,1,1,3,2 +.?.?????##?#??##??? 1,1,13 +?.??????#????? 7,3 +?..?.?????#??? 1,2,2 +?.?????##??.???#??. 1,1,5,1,3 +????#?#??????#????.? 3,6 +??##??????? 4,2 +??.?#??#?????????.?? 5,4 +??#?#.?##?? 3,3 +?#??.??..?? 2,2,1 +????...?.??????#.#? 1,1,1,5,2 +????????###.? 2,6,1 +?.#?#??????#? 1,10 +?.?##??????.???? 1,6,1,1 +#???????##?? 6,2 +??##???.?.?#??#??##. 5,1,8 +?##..??##??#?. 2,5,1 +#.??.#????#?#?? 1,1,1,1,6 +.????..??#?. 1,1,4 +?..????????.#.. 2,1 +???#???????#??? 5,1,4 +???.???.???? 2,3,1,2 +??..#???##.??. 1,1,3,1 +?????.???????????# 1,1,1,1,7,1 +#???#???#????. 1,6,1 +##??#??????.?? 5,3,1 +.???#?..???.??? 5,2 +.?##?##??#?.#??#? 3,6,1,3 +.??#.??#???.??? 2,5,1 +.#.???#??##?#.????? 1,7,1,1,1 +##?.#???##?#??? 3,10 +#??.??###.?#.## 2,4,1,2 +??#???????#?.???# 5,6,1,1 +????##?#???.??# 2,4,2,2 +#?..???##?.? 2,5 +..????#??.? 2,2 +.???#?????. 2,1,2 +?#?..??..#???. 2,1,1,2 +????.???##????????. 1,1,1,10 +#?#?#.#???.?#? 1,3,3,2 +..##??????.????? 4,1,2,1 +??#???????? 4,2,1 +???.?????#. 3,1,1 +.#?????????? 3,5 +.???.???.?##???##?.# 1,2,8,1 +???###??#..???#????? 8,6 +?????.?????# 1,1,1,1 +???#.??##?#?.?.???? 1,1,4,2,1,1 +?.##?###???.???????# 1,9,1,2,2 +..?.??.??#????????? 1,6 +???##???#??????# 5,3,1,1 +.#??.???.?####?? 3,2,6 +??##??#.?#?.#??#???? 6,1,1,2,1 +.???#??.????##?? 5,7 +.?????#?.??# 1,1,2,1 +??..#???.???? 1,1 +?.??###???#.?.#???? 1,4,1,1,1,1 +??.?#.???? 2,1,1 +????#???.?#..###? 5,2,4 +???#????#? 3,2 +.?##??##???#?#?????? 9,1,1,3,1 +??#??..??#?#.?? 1,1,1,5,2 +#????#.???????? 1,4,1,1 +??##.??###??# 2,1,3,1 +???#?#??#? 1,1,1 +????????.??.?.#.#? 5,1,1,1,1,1 +?#??.??#.?.??#? 3,1,1,1,2 +?##?.#??#? 2,4 +???#????.?.?? 6,1,1 +?.???.???????? 1,1,6 +??.??.?.???..? 2,2,1,3 +?????#..?????. 1,1,2 +??#???#??#?#.?.? 1,10 +.??#????##?????. 5,3,1 +?.#?.??#?#? 2,1,4 +?.?#?####?.?.???.?.. 8,1,2,1 +??????#??.? 5,1 +?#??#????????? 5,1,1 +?..?????????###??? 1,1,1,3,7 +????????.?.?..?????? 1,1,4,1,1,5 +..?????.#???#..# 2,1,3,1 +???##????#.?.?#? 8,2 +#.???.###? 1,2,4 +?#.??..????## 2,1,1,4 +..??..#??. 2,2 +????.?.#??? 2,1,1 +??#??##??????.??#??? 10,1,1,1,1 +.##?..#?.?..#?#?..?. 2,2,4 +??..??????#?#. 2,2,3 +??????#???.##?##?? 1,5,1,6 +???#?.#???# 3,1,2 +#?????#?##?#.????. 3,7,4 +??#??#??#?#.?. 2,2,4,1 +#???????.. 4,1 +???.?.?###? 2,1,3 +?#?.?????##?#.#??. 3,1,2,2,1,2 +?#??????#.?? 1,1,2,2 +.#.?##????## 1,3,3 +.#?????????? 2,6 +?.????.??# 2,2 +..?##??.??.?##? 2,2 +???##?#????# 8,1 +.????#????.?. 7,1 +?.???..#?#??? 2,4 +?#???.#?????..#??## 4,3,1,2,2 +?????.?#??.???.? 1,2,3,1,1 +?.?#?????#???.. 1,2,1,1,1 +?#???#?#?.???#??#??? 9,1,7 +?????????. 4,1,1 +..#??.??.?#???#.?? 2,6 +.??????.?# 1,1,1 +???#..?#???#?##??# 1,1,10,1 +?.??..?#?? 1,2,1 +???#?.??#?? 3,5 +??#????????#? 3,1,2 +????????##?????#??. 6,2,1,3 +????#???.?#???.? 4,1,1,2,1 +.?#?????....?#??.??? 1,2,4,2 +???##???##?#???.? 12,1 +?.??????.? 3,1 +?.?...###????#?? 1,10 +??#??????#?.? 4,2 +.##?#.#????.? 2,1,1,1 +#???.????.?## 1,1,1,2 +?.?#?.??##??????? 2,2,3 +??.??????##?.??? 2,1,7,1 +?#??.???????????? 4,1,6,1 +?#??..???#?? 3,1,2 +.???.???##.? 2,4 +#???#??#.? 2,2,1 +????#????? 2,3,1 +?????#?..?????? 2,3,2 +????????#.??.??..?? 7,1 +?????#??#.?#???? 1,3,1,5 +????????#?? 2,1,1 +????.#?????.???.???? 1,1,6,1,1,1 +#????#?##?#?#??? 1,12 +???#??#??.???????? 5,2,1 +#???.#??.?.. 1,1,2,1 +?.?????#.?.??. 3,1 +#???.???????.??? 2,1,2,2,3 +.#??????#### 1,7 +?.?.?????#???? 1,2,1,2 +?????.##???##? 3,7 +??##????#??????.?? 5,1,1,1,1,2 +.#?#?????. 1,6 +.?#??.???? 2,3 +#.??#???#?????.#?#.? 1,11,3,1 +.?.??#?#?????###?. 8,3 +??????.???. 4,1,2 +.#??.?????#? 1,1,2,4 +???#.#?#?#? 4,1,3 +??###..#?? 3,2 +????????#??.#? 3,2,1 +.????##??..#??. 1,3,3 +?????.#???.???#???? 2,2,1,2,3 +??.???.????????#?.# 1,1,4,4,1 +?.??.??##????#???# 1,1,13 +.??#?#??..?##???? 3,6 +????#??.????##.. 3,1,1,1,2 +??.?.????#?.? 1,1,2,1 +????????#?#?#???? 4,11 +.??#?##?.?.?? 7,1,2 +???????????#????#? 2,1,1,2,7 +??#??????? 1,3,1 +###?.#?????#? 3,1,1,3 +????#?#?##??. 1,8 +??????##?##??#????. 1,2,9,1 +?.?.??????#? 1,1,3,3 +??????.#?#.??#? 1,1,1,1,2 +.??#??????????#.?# 6,1,1,1,1 +?#??#?#????.???. 7,1,1,1 +?.??#????#??.??.??? 1,1,1,6,1,2 +???.#.#.??.#.?#???? 1,1,1,1,1,5 +.#?.??????#????.??# 1,2,6,1 +.??#?????? 1,1,2 +.#??#????????.?????? 10,1,2,2 +.#????.?##? 1,1,3 +???#?##???.?#????#. 6,1,6 +??.???#??.??#?#?... 3,3 +#?#?.?#???.?. 1,2,3 +????.?#?#????#?#. 1,10 +??????.#?.?? 2,2,1 +?.##?..??.??##???? 1,2,2,1,2,2 +.??#??.?????.??? 3,2,2 +????#?#.?#??# 1,4,4 +???#????.?#.?.? 2,1,2,1,1 +???????????.#???. 4,1,1,1,4 +#????#?#?..??? 8,3 +?.???????. 1,4 +?#??#???????????? 6,1,2,1 +?#?????#.??#?##??. 1,3,7 +..???##??#?????????. 10,2 +????#??#.??.????? 1,6,1,1,3 +?.???.???????.??.. 1,3,3,1,1 +.????????? 2,2 +??.#?.?#????.?..?? 2,6 +?.???#????### 1,5,4 +?.??#????? 3,1 +??#???#.??#?? 2,1,1,1 +????##????????##? 1,2,4 +??.???#?.??? 1,1,2,1 +???.???#??.#????. 1,5,1,3 +.?#?????????? 2,2,1,1 +##???.???#.##?### 2,1,3,6 +?.?.#?..??#?????#?.# 1,1,1,7,1,1 +.#????.???#????. 4,2 +?#????#???#??? 1,2,1,4 +??##???#???#???? 5,5,1 +????#??????#??? 7,3 +.#???#?.???????.#. 3,1,1,1,1,1 +????#?????..?.??? 9,1,1,1 +.#?#?#??###?????.? 1,1,1,8,1 +?#???#.????. 1,1,1,1 +??????.????? 3,1,1 +.????????..? 2,1,1,1 +?????#?#??#. 2,6 +??????#???###???? 7,4,1 +..??##?????????#??. 6,2,1,1,1 +??#??##??.??#.???? 8,1,1,1,2 +?????###?????#?#? 9,5 +??..??#?.. 1,1,1 +.??.??????????##??? 1,4,6 +#?.?????#??#.??.??? 2,3,5,1 +?#??????#?#?? 2,3,1,2 +.??#??#????#?#.? 1,8 +..??.??.????## 1,2,1,3 +???###???# 4,2 +???.????#?#??#?#??? 3,2,10 +?#?.#.?.?####? 2,1,1,6 +???..???.#???????? 2,1,3,2,1 +??.?.?#??.#??# 1,2,2,1 +???##??### 2,2,3 +?#????.?#??????.?#?? 5,1,2,1,2 +..????#???# 1,2,1 +????#..??##??? 1,1,1,3 +##?#??##????#?.?? 10,1,1 +#???###?????? 7,1,1 +??????.??#?????##?? 4,1,5,1 +?.??????#???? 1,3,4,1 +???????#?##???..?. 1,1,8,1 +??#??##?#?#????. 9,1 +????###????????.?.?# 3,5,4,1,2 +??.?#???.?.??????. 1,1,2,1,4 +##???###.?????##..# 3,3,1,2,2,1 +??#??#?#.?.??#????? 6,4 +#?#???????#??#?#?#?? 3,1,2,4,1,2 +???#?????.?. 1,1,1,1 +?#.?#.????? 2,1,2 +???#??#?#??#?##??.? 4,1,9,1 +?...##????.??#?.? 1,3,1,3 +??.?.??#?#??#. 1,6 +???.#.??#???.? 1,1,2,1 +.??..???#?#???? 2,6,1 +?##??#?.?? 5,1 +#??#??#????.. 1,7 +??.???#?..#?#?????. 2,8 +???????#??#.???#? 1,1,3,1,2 +???????###?#. 3,3,1 +???.#?##????#?#?#? 1,5,8 +#.?????#??.???.#?? 1,1,3,3,3 +#??#???????????#??? 1,2,4,1,2,1 +???.?#.?###?.#.?# 1,1,4,1,2 +???#?????.?#???#? 4,3,1,3 +?#??.?..?#???? 4,3 +??#?#.#.?? 4,1,2 +???????.??#.?#? 1,2,1,1,2 +#?#?##???.????#?? 1,7,1,1 +??#??#?????#??. 7,2 +.?.??#?.???.?# 1,3,1,1 +.?.?????#????##?.. 1,1,1,3,3 +#.????.???????.?? 1,3,4,2,1 +???????#???????.??#. 1,2,1,4,1,1 +.?#?..??##. 2,4 +.?#????????.?????? 9,6 +?#????????.???# 3,3,1,1,2 +??.???#???? 1,3 +??#????????????? 8,1,2 +?????#???????#???#? 3,2,1,5,3 +??.???.???###? 1,2,6 +?#..???#..? 1,3,1 +??#?#??????#.#.??? 10,1,2 +???.??#???##??#???. 2,10 +?..??..?.??#?? 1,4 +????.??.???. 3,1,2 +???##??..??. 5,1 +??????#.??#????? 1,1,5,1 +???#???#????#?#???? 1,1,4,1,7 +.?..???#?.? 1,1 +?.???#??#?????##???? 1,2,5,7 +?#???.???#??.?????# 2,2,3,5 +????#????.#?.#? 1,5,1,2 +??.?#?#.?? 2,3,1 +?.?#?????#??. 5,2 +.????..????????? 1,1,1,1,4 +?#.????.#??. 1,2,2 +????..#??#?#?##? 1,9 +.?###????? 4,1 +?????#?????#?##.? 4,4 +#?.#??.????????##? 2,2,2,8 +????.????????#?... 2,1,1,3,2 +??.???.?.??. 1,1,1,1 +?##?.????##??##??? 3,2,8 +?????????#??#?????? 3,9,3 +#?.#??#?.?#????? 1,1,3,2,1 +???.#??#????#???.?? 1,1,6,4,2 +???#...###??????. 4,5,3 +???????#...?? 2,4,1 +#??#?#??#?#?. 7,3 +?.?###????###??? 3,7 +??#..?????????? 2,2,2,1 +.??????????#?? 1,1,1,3 +#??#?????#???.??#?? 10,2,1 +?..?.#??#.??? 1,2,1,1 +#..?????#..# 1,1,3,1 +#?#.??#???#?? 3,3,1 +#??#????#?.???.??? 1,1,3,1,1,1 +?.?.??????#?#.#?#? 1,1,1,5,1,2 +#?.?#????#? 1,2,5 +??????..#??#?????.? 1,1,1,5,2,1 +????#??#????? 4,5,1 +?..?????#??#????.?? 1,10,1,1 +??#?#???.??????? 6,1,2 +#?.??#??#?. 2,1,2 +????#.??.??? 1,2,1,1 +?#?#.???#?? 1,1,2 +?.#??.?.??# 3,3 +.?#.###?#????#?.##.? 1,11,2 +?.????#????.???#?? 1,1,1,1,1,3 +#.?#??.?#??#??? 1,2,5,1 +.?#????????.??# 5,1,1,1 +???.#?.????? 2,2,2,1 +#????#??#?#??.???? 13,1,1 +?#?#?????? 4,1,1 +???##??????.??.???. 5,2 +?.????.?..#. 1,1 +???????.???#?#?##.. 1,2,8 +.#.?????#.?.#?????.# 1,4,1,1,1,1 +???##?.?????? 4,4,1 +?????#???####? 2,9 +.????#.????.# 5,2,1 +??#?..#?#???# 2,1,2,1 +??##.#??#?#????#?. 4,2,1,1,2 +#.#???.?...?#????#?? 1,1,1,1,7 +?.????.??????#?.#? 1,2,1,5,1 +??#???.???#??. 1,1,3,1 +?##?#?#???#.#???? 10,1,1,1 +.?#???????????. 1,2,5 +???????..??#?#??? 5,1,5,1 +.???.#?#??????##??#. 1,14 +?#??.?.???.#? 4,1,3,1 +..??##???????#.?? 5,5,1 +.#?????#??? 1,5,1 +#????#.?.?????. 3,1,5 +?#?##?#?????# 5,2,3 +???????#?.?..?????.# 7,1,3,1 +?#??#??.?? 1,4 +???#..???. 4,2 +??.#?#.?#?? 1,3,1 +???#??##??.#???#? 2,3,5 +???#?????#??.???.?.? 11,2 +.??..???#??? 2,4,1 +?.?#.?##?.?#?.? 1,2,2,3 +??#??????#?? 3,3 +.?#??#???? 2,5 +????.??????#???#?.? 3,2,7,1 +???#?..#?.?#???#?#? 2,2,2,6 +.??#??#?#.??.#? 2,1,1,1,1 +.?###..????#? 3,2,1 +?.?????????? 1,4,1,2 +?#??#???..???#? 6,4 +???#??#??.#? 3,1,1 +???.?.####?.# 1,1,5,1 +.?????????.?.? 5,1 +.???????#???#?. 1,9 +.??#??#???.??#. 4,1 +#??#..##?.???. 4,2,3 +.????.??.?#?.?.?#?. 4,1,3,1,1 +??.?#??????#??????.? 1,3,3,3,1,1 +#?????.?#?.#??.? 1,4,1,2,1 +?.?????????.? 3,3 +?????#???#?? 5,1 +..??#???#???.#.#.? 6,1,1,1,1 +??.#.##??? 1,1,4 +?#??????##.##?. 1,2,3,3 +.???#.????? 3,3,1 +.???#?#????#??.?.?? 7,1,1,1,1,1 +..??#??#??#???.?##?. 6,1,3 +??#???#.???????? 7,1,3 +???.#??.???.???# 1,1,3,1,2 +??#.##?#?? 2,5 +.???#?#.#???????? 4,1,2,2,1 +?#?#.?##????#? 2,1,4,2 +?.?.?.#????#??.?? 1,1 +.???.#????.?.?????. 2,5,5 +?#?.??.????? 2,1,3 +????###?#?.????.#??. 7,3,1,1 +?..?#?.##? 2,2 +?.?????.##???#.??## 1,1,1,6,1,2 +??#?.?.#???.? 1,2 +???.#?.#?????#. 1,1,2,2,4 +..??????????#? 1,8 +??##?#?.???? 3,1,1 +?#?.???#.?? 2,1,2 +##???##?#???.?? 7,2,1,1 +???##??##??#.?.???? 11,1,1,1 +??.??????##??.#..?? 1,6,1,1 +????#?#?.??#?? 6,1,1 +.???.#.#??.?#? 3,1,2,2 +??????.??#.??.?#?.? 5,2,2,3 +?.??#?????#.?#??##. 1,3,1,1,1,6 +?.???#???#?#?.????? 2,1,6,1,1 +#.##?????????#? 1,3,1,2,2 +?.#??????. 4,1 +????.??.????#?????#? 3,1,1,1,6 +??##?#?##???# 9,1 +?#?####.####??? 6,4 +??.#??.????# 1,3,2 +.????#??.?#?? 6,3 +??????###?.???.??? 2,4,1,3 +.??#??.????#?? 4,1,1 +??.#?????#???????# 1,5,3,1,1 +???????##?#??#??#??? 1,10,1,2 +????#??#?####?.#. 3,2,5,1 +#???##???#.?.???# 7,2,4 +??#??.????? 3,3 +?#??..?????. 1,3,1 +???#???#.??.?##?. 6,3 +??#??.??.??.#. 4,1,1,1 +??????.??#?#??..???? 1,3,5,1,2 +??#?##??#.??.?# 6,1,1 +###????.#????.##.? 3,3,1,1,1,2 +#?#?#?#?#??#???????# 1,1,3,6,2,1 +??.#???#???????? 5,6 +?.???????.? 1,1,2 +?????????????? 1,5,2 +????????#? 2,3,2 +???.???.?###??#?? 2,1,4,1,1 +????????#?#??? 6,3 +???????#??.? 1,1,4 +.#??.#?#??? 3,4,1 +???###????.????#. 7,2 +.???#?????? 1,3,3 +???????????????#.?#? 2,2,6,1 +.###??..?? 3,1,2 +?..????#.????.??#. 1,5,2,1,1 +??#????.??#???.. 2,4 +###???.??#?#?..???? 6,6,1 +?#????????. 4,4 +?#??????????? 5,1,1,1 +??..??.#????. 1,5 +?.?##.?????? 2,5 +..??????#?? 3,1,1 +???????#???????#?. 2,9 +?.?.#?.?#.??#?#??# 1,1,2,1,8 +????##???#?????..??? 11,1,2 +?.??.??.#?? 1,1 +.??#???#?#?#?.??# 4,5,1 +#??#??.??.##?.#??# 5,1,3,4 +.#.##??.???????#?##? 1,3,4,7 +..??.?#?#???#?#?.? 1,1,3,4 +.??.##???..???????#? 5,1,7 +??????...# 2,1,1 +?????#??.#.? 1,2,1,1 +??#???#?#??#??? 9,2,1 +????????#?????.. 2,8 +?????.?#???#..?#???? 2,1,4,1,3,1 +.?????.??#?? 3,2 +#?????#?#.#???#?? 3,3,1,2,2 +??#????###????.???? 11,1,1 +.??.????.??? 1,2 +#.#???#????#???.#.?? 1,7,1,2,1,2 +.#.###????? 1,6 +??????##?.?..?#?. 7,1,2 +.###?#??????#???? 5,7 +??#??#.##??.?.??# 4,4,1,1 +???????#?#?? 1,5 +??????????##.??? 1,4,4,3 +#?##????..??# 7,1,1 +#?????#??#????.?? 1,1,5,1,1 +.?#?#.#?.??????#?? 3,1,1,1,5 +?.?#.?##???#..#. 1,5,1,1 +#??#?????.#?.?????. 6,1,1,1,2 +.?#???.??##??.?? 4,6,1 +??????#???#???????#? 13,1 +??#??##???????.???? 9,2,1,1 +#?#???#..#??????? 7,1,1,1 +????????.?#??#??. 2,6 +?.???.##????#?####?? 2,2,8 +?..##?????#?????#? 2,2,7 +..???.???.# 2,1 +???#.????.? 4,3,1 +##?????#????.?????? 2,5,3,3,1 +????#??##?. 3,2 +??#??.?#?..????.?? 5,3,1 +.?..?????..##???.??? 1,4,2,1,1,1 +.??????##???????? 7,1 +??.?????.? 1,4 +....??.???# 1,2 +.??.????????????? 1,9,1 +??#?#????#.??#????#? 9,9 +??.#??#??.?? 4,1 +??.??#?????? 1,6 +.#?###..#???????.? 5,1,6,1 +.????????.??.?? 8,2 +#??#.?#??#??.#? 4,4,2 +?.????.????????#?. 3,9 +??###????????? 8,1,1 +?#.##??.#? 1,2,1 +????????.#??#. 8,1,1 +?..#?.?..##???##??? 2,10 +.?##?##???.??????#?? 6,2,1,4 +?.????.??.##???.?? 2,2 +.????.?????#???? 4,6 +???.??????? 2,2,4 +????.?#?????.???#? 2,5,5 +?.#??????????..?#.?? 1,5,1,2 +????#.?###?????##??? 5,12 +??.??#???????#????. 1,1,1,4,2,1 +.?????#???? 1,4 +???##??????## 6,2 +#?#?????.???.?#?.? 4,2,3,2,1 +??#?##?##?#?????#?? 9,1,5 +?????#??## 5,2 +?#.????#??#????#?? 1,1,4,1,4 +??.??????#?#.?? 2,8,1 +?????.????. 1,1,2 +..?.??????????????? 1,1,1,4,1,1 +?.?#??#???????#???.? 7,6,1 +???##?.#???#?#??? 5,2,6 +?##?##??????? 6,4 +##?.#??#?. 3,1,1 +?.?#?.??#.?? 1,1,1,1 +?.???#?##?????#. 1,8,1,1 +?.?.??????#???## 1,1,1,1,4 +.???##???.# 4,1 +??#?##???.. 7,1 +#.???#?.#.???? 1,4,1,2 +?.?#????#?? 1,2,4 +#?.#????#??????????# 2,1,1,4,1,5 +??????.?#??.?##? 3,1,2,1,3 +???#???.???#?#?#??. 3,6 +#??.??#..? 3,1 +????.???????? 2,1,1,1 +??.??#?#..???????? 1,4,8 +##?.?????? 2,2 +?..#?.##????????# 1,1,11 +.#?#???.?#???.?? 1,1,2,2,1 +???????.??##?? 2,1,4 +???#?.#???????##? 2,2,1,7 +???????.??.??. 2,1,2,1 +?..?#?..???#?? 2,1 +???#?.#?.????#?.??? 4,2,5,1 +??#??.#???#??.?#?. 4,1,3,1 +?.????..?????#??# 3,1,5 +???##??#???#.?? 1,5,2,1 +?????.???. 2,1 +?????#.??.?? 6,1 +?#????????. 1,5 +????.???#??#????.# 4,2,1,3,1,1 +?#.?#?#.##?????##? 1,3,9 +????.???#.#?##??.? 1,1,4,1,4,1 +#.??.?.??##????#?#? 1,1,1,5,1,2 +???.?????##?#?? 1,4,2,2 +????#?.?.? 1,1,1 +?#??.?...?#???????.? 2,1,8 +??##???##?? 4,2 +????#??#??#??#??? 11,1 +#?????????##???? 4,9 +????????#????#??#?? 1,15 +???.#?.?#? 1,2,1 +?.#..#???#??. 1,1,2,3 +?.???????? 2,4 +????????#????#?.? 1,1,7,1 +??..????????.?.??#?? 7,3 +#??????#??##.. 1,2,1,2 +?.?##????#.?...?. 3,1 +#?#?#?###??##?#? 9,2,2 +?.##???#?#???#?#?? 2,12 +##?.?#.#????#?? 2,2,7 +????#?#??#???. 5,1,1 +?????#.?.###??.??? 6,4,3 +????#?###??. 1,1,3,1 +?????#??.?#????. 1,5,2,1 +???.??#??#?.??#?.??. 3,7,3,1 +.?#?.?#..?#?##??#.?? 3,1,7 +?.#????#.????#?#? 3,1,1,6 +#??.?????..????.???? 1,4,1,2,3 +?###????..?##?? 8,4 +.#???????#?##?#?? 1,1,1,1,5 +???##?????#?#??#.?.# 1,11,1,1,1 +?????????? 2,2 +????#??.#??? 6,1 +#????????????.?##? 4,1,2,2,2 +?.?##?#????#???#?#.? 1,4,9 +?#.?###?.??????#??.? 2,3,8,1 +?????..#?..?? 3,1,2,1 +#?#?#?#?????.?# 5,1,1,1,1 +?#???#??.#??# 1,4,4 +??#??#?##?? 2,5 +????#.#???#???#??.# 1,2,3,6,1 +#???..#?#???????.?# 3,1,2,1,1,1 +?????#????? 1,4,3 +?????.?????#?#????. 2,1,1,5,1 +???#??????#. 2,3,2 +#??.?????? 1,1,4 +.?#?????.???????? 3,1,1,4 +#.???????????#?????? 1,4,1,1,3,1 +?.?###?#?????#??. 4,1,6 +?#?##??????? 6,1 +.????#?#### 1,2,4 +???..?#?????? 1,1,1,3 +?#?.??.?.#???#??? 2,1,2,4 +#?????????.?#??#??? 2,2,2,1,1,1 +???#?????????. 1,3,5 +##.??.#.?.?##??#? 2,1,1,7 +.???##?.?.##? 4,3 +??##?????#???#? 4,7 +.?.??????##?..?????? 8,1 +??#???????#???.?? 1,1,1,5,1 +.#??#?#???????#???. 1,4,1,2,1,1 +??.????#?.##. 1,2,1,2 +?#?????#??.???#?. 2,2,3,3 +?#?????#??????#..? 13,1 +??#.???#???#??..?#? 1,9,2 +##??.?...?????#? 3,1,1,1,2 +#?.??#??.? 2,2 \ No newline at end of file diff --git a/inputs/12_test.txt b/inputs/12_test.txt new file mode 100644 index 0000000..c5bec3a --- /dev/null +++ b/inputs/12_test.txt @@ -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