From aaa182463434be4fe744f9d7d264ee5585998889 Mon Sep 17 00:00:00 2001 From: Siegfried Puchbauer Date: Tue, 12 Dec 2023 02:24:35 -0500 Subject: [PATCH] 2023 day 12 --- 2023/day12/.gitignore | 2 + 2023/day12/Cargo.lock | 278 +++++++++++ 2023/day12/Cargo.toml | 9 + 2023/day12/src/input.txt | 1000 ++++++++++++++++++++++++++++++++++++++ 2023/day12/src/main.rs | 245 ++++++++++ 2023/day12/src/test.txt | 1 + 2023/day12/src/test2.txt | 1 + 7 files changed, 1536 insertions(+) create mode 100644 2023/day12/.gitignore create mode 100644 2023/day12/Cargo.lock create mode 100644 2023/day12/Cargo.toml create mode 100644 2023/day12/src/input.txt create mode 100644 2023/day12/src/main.rs create mode 100644 2023/day12/src/test.txt create mode 100644 2023/day12/src/test2.txt diff --git a/2023/day12/.gitignore b/2023/day12/.gitignore new file mode 100644 index 0000000..2a7f9d1 --- /dev/null +++ b/2023/day12/.gitignore @@ -0,0 +1,2 @@ +/target +/temp \ No newline at end of file diff --git a/2023/day12/Cargo.lock b/2023/day12/Cargo.lock new file mode 100644 index 0000000..853bd77 --- /dev/null +++ b/2023/day12/Cargo.lock @@ -0,0 +1,278 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + +[[package]] +name = "aoc" +version = "0.1.0" +dependencies = [ + "itertools", + "rayon", + "sscanf", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "const_format" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a214c7af3d04997541b18d432afaff4c455e79e2029079647e72fc2bd27673" +dependencies = [ + "const_format_proc_macros", +] + +[[package]] +name = "const_format_proc_macros" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f6ff08fd20f4f299298a28e2dfa8a8ba1036e6cd2460ac1de7b425d76f2500" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "convert_case" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +dependencies = [ + "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" +dependencies = [ + "autocfg", + "cfg-if", + "crossbeam-utils", + "memoffset", + "scopeguard", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + +[[package]] +name = "itertools" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25db6b064527c5d482d0423354fcd07a89a2dfe07b67892e62411946db7f07b0" +dependencies = [ + "either", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "memchr" +version = "2.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" + +[[package]] +name = "memoffset" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "proc-macro2" +version = "1.0.70" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rayon" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "regex" +version = "1.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax 0.8.2", +] + +[[package]] +name = "regex-automata" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.8.2", +] + +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + +[[package]] +name = "regex-syntax" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "sscanf" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c713ebd15ce561dd4a13ed62bc2a0368e16806fc30dcaf66ecf1256b2a3fdde6" +dependencies = [ + "const_format", + "lazy_static", + "regex", + "sscanf_macro", +] + +[[package]] +name = "sscanf_macro" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84955aa74a157e5834d58a07be11af7f0ab923f0194a0bb2ea6b3db8b5d1611d" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "regex-syntax 0.6.29", + "strsim", + "syn", + "unicode-width", +] + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "syn" +version = "2.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13fa70a4ee923979ffb522cacce59d34421ebdea5625e1073c4326ef9d2dd42e" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-segmentation" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" + +[[package]] +name = "unicode-width" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" diff --git a/2023/day12/Cargo.toml b/2023/day12/Cargo.toml new file mode 100644 index 0000000..a362505 --- /dev/null +++ b/2023/day12/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "aoc" +version = "0.1.0" +edition = "2021" + +[dependencies] +itertools = "*" +sscanf = "*" +rayon = "*" \ No newline at end of file diff --git a/2023/day12/src/input.txt b/2023/day12/src/input.txt new file mode 100644 index 0000000..12d6f3c --- /dev/null +++ b/2023/day12/src/input.txt @@ -0,0 +1,1000 @@ +##.??.??##? 2,2,4 +???????##?????#?#? 9,6 +???#?????? 1,1,1 +#???..??##..?# 1,2,3,2 +??.#??#??? 2,1,3 +#??#???????????.??? 14,2 +??????#?.#?#.????.? 7,1,1,2,1 +.??..???????? 2,1,3 +???#??#?#?#?.. 1,7 +????#??#?#?#???####? 4,13 +.#..?.???# 1,1,3 +.#?##.???.????#. 4,3,2 +.??#??#?????????# 6,8 +?#?.??#?#.???? 2,4,1,1 +.??##?#????.?? 5,1 +??#?.???##???? 4,3,1 +#?#?#?..?.?#? 6,1 +?.#??.??##??????? 1,1,1,8 +?????#???????????#?# 1,4,1,2,1,1 +.???.?.????#?? 2,1,1,3 +..?#?.#?#??#?.?? 3,7 +???#?#?##?##???#??? 1,1,12,1 +?.??.???#. 1,1,2 +???#?###????# 1,1,5,2 +?.????#?????#??##? 7,6 +??#??#?.??? 6,2 +???#??.???????#? 4,1,1,1,2 +##?##?#??.??#.#? 8,3,1 +??#????##.?? 9,1 +?..???????? 3,1,2 +????##?????#?#?#??.? 3,7 +.?..?.???.?#???????? 1,1,2,6,2 +?.?#????#.??? 4,1,1 +#??#??#????.#?? 8,3 +????????.??.##?? 2,1,1,2 +???.???#??? 1,5 +?????#.#?? 2,1,1 +??#?.?#?#?????.#?? 2,4,3,1,1 +?#???.???.##? 3,2,2 +???#?#???????.?. 4,6 +?#????###?.???#?#??? 8,9 +.?????????? 8,1 +?#???##?#?? 1,2,2 +??.?##??#??? 2,2,3 +?????#?#???#?. 7,2 +#??????????.#.?..?#. 9,1,1,1,1 +?.?##?#???.??#??? 1,6,5 +???.??#?#?#.#??.. 3,7,2 +?.???##?#.#? 1,6,2 +???#???????.?#????#? 1,2,4,7 +??#?#???#?.? 8,1 +?.?#.?.#???..? 1,4 +#.?.????#??###.???## 1,2,6,2,2 +???????.????. 5,4 +??.#?????#?#????#?? 1,10,1,3 +???#???.??? 3,1,1 +?????.#??#.? 1,4 +???#?.?#???????? 3,4,1 +.???????#?????.?#?? 4,4,1,2 +?????????.?.#???#?? 7,1,1,2 +###.?#???#. 3,6 +...##?##?#???? 5,5 +?#??#????.? 1,4,1 +?.?????????#? 6,4 +.?????###?#? 1,6,2 +.?????#???? 5,1 +??????.???????. 1,1,1,2,1 +?.##?#??##??#??##?# 4,11 +?##??#?.#??.?### 2,1,1,1,3 +?.?.??????. 1,3 +.?.?.?#????.??#?... 1,2 +?.???#?##???#.?.? 1,5,1,1 +.?..?###????#??????? 12,1 +?#???#.?#.?# 2,1,1,1 +??..#????#?????..?.? 2,7,1 +????????.?????????? 8,3,1,1 +##???..??? 2,1,2 +??#???#???? 1,2,1 +.????#??###.??# 10,3 +??????.##???????#? 5,5,3 +.##???????####.?. 3,9 +.#?#???##?.???#?#?? 3,3,7 +????#?#?????.?#?? 1,10,3 +???#??.#.???##?.#? 2,3,1,1,3,1 +.#?.??????????#????? 1,13 +??????.?#??##?#?.? 3,1,5,2 +.??.?#??#?????????.? 1,5,2,1,1,1 +??????#.?? 2,2 +.#?##??#?#??..#?.??? 5,5,1,1 +????.????#??# 1,7 +#????...?????#? 4,2,1 +??#???.????#??.??. 3,1,2,1,1,1 +.?????.????. 1,1 +??#???#?.? 1,2 +?.#???#?????? 1,7,1 +.??##?.#?.??#??#???? 4,2,7 +#??#?#??????.#?#?? 1,5,1,1,1,3 +.?#??##????...??##?. 9,4 +?##??????#?#?##? 2,2,3,1,3 +.?#??#.#???? 4,1 +??????.?#???.?#.#??# 4,3,1,1,2,1 +??????.#???.??? 5,1,1,1,1 +?.??????.#? 1,2,1 +?##?.????. 3,2 +??.???????#???#? 1,1,2,7 +??#.#?#??#??.? 2,7,1 +??#??#?.?#?. 6,2 +.?#??????? 1,1,1 +.#??.????#?#.? 2,2,3,1 +##??#??.?? 5,2 +?#?#??#??#### 7,4 +???###???..? 8,1 +##???????. 2,1 +???#???.?????.??# 1,4,5,2 +?..??????????##??? 1,1,4,4 +?#??????##??..??. 1,7,1 +.?#??.???#?#???#?.? 3,8 +?###???#???####. 8,5 +?.????#?#??????????? 1,1,1,9,1,1 +??#?????##?#??. 1,7 +?####????#????##???. 7,3,5 +????.???#? 2,5 +??#????#???..??#?? 1,2,6,5 +.?.???#?..???? 1,4,3 +#?#????##???. 3,1,4,1 +??.#?????#?. 1,8 +???????#??#? 3,1,1 +?#?#??.?.?.????.. 6,3 +?#?????????? 2,2,4 +??#?#??#????????# 12,2 +????##???.????? 1,5,3 +#?##..?#.? 4,1,1 +??.#???.#????#? 1,4,1,1,3 +??##?????#?### 1,4,1,3 +??###??.?#.#????#?. 7,2,2,1,2 +????##????.# 6,1 +??????????? 2,2,2 +???.???..?.?#.?..?? 1,1 +???#???#.?.#??? 1,1,2,1,1 +#?.?..??.???????. 1,1,1,2,3 +?##??????#??? 4,1,4 +???????##????? 1,8 +##?????#????.#?? 8,1,1 +.#..#?#?#.?.##??#?? 1,1,3,1,6 +???##??.???? 1,3,1,1 +?#????.#??? 5,3 +?.??##??.?#??#?.??.# 6,2,1,1,1 +??#?#?.??.#??...? 3,2,1,3 +?????#??.. 3,2,1 +.??#?...?#?#?. 4,5 +.????#???.???. 6,3 +????.?#???...?.?. 5,1 +??.??.?###???#?? 1,2,7,1 +????.?.?#?# 1,1,3 +.???#?#...??##?#? 6,6 +###???.??.??#?????? 3,1,1,2,1,1 +?#..???.???# 1,3,2,1 +##??#????. 2,3 +##??????###???##..# 7,8,1 +?????#????..???#???? 9,4 +.?#??##?.?##??#. 2,4,3,1 +?#????.#??.????#.? 4,1,3,2,1,1 +#?.#???.??#?.??. 1,1,1,4,2 +?.??#??#?#??.?#?. 9,1 +.#???#.???.?#?#..?. 1,3,3,1,1,1 +?????#?.?.?# 3,2,1,2 +.???????.??## 1,5,3 +??.?????#.??? 1,5,2 +??.????##..?#.??# 1,3,2,2,2 +.#????.?#???..???? 5,5,2,1 +????#?##???#. 5,2 +?.?.????#????#. 1,1,1,2,1 +#.?#.???#???##?# 1,2,10 +?????.?.???????????. 1,7 +.??#??.?.????? 5,1,1,1 +???????#.. 4,2 +?.#??????.??#?##??. 5,6,1 +.????????????? 3,1,1,1 +?#????????.?? 1,2,1,1 +#.????.??#..? 1,1,1,1 +.?#.?.???????? 2,1,4 +??#?#??#?#????..? 1,1,1,8,1 +##??????.#.? 2,3,1,1 +??#???.??...??.? 1,4,2,1,1 +????#?#?#..?.????. 9,1,1,1 +????.#.?#??#???????? 2,1,10,1 +?????#.??????.. 1,2,2 +??.?###..#???? 4,3 +#???#??.???????? 6,4,3 +?#????#??? 1,3 +??##?.?#?#????.??. 3,5,1,2 +##.?.###?????.?#?? 2,5,3 +??.#??????#??????. 8,1 +?#?#???.??#?????.. 7,7 +##?...???##???##??? 3,12 +.???#??????#???.???# 5,5,1,4 +??.??..????? 1,1,2 +??????????.??? 5,2,2 +#????.???? 5,2 +.?#?#????# 7,1 +#???###.?##?# 1,3,3,1 +???#???.#.?# 3,1,1 +#??????#?#?#??????## 1,7,1,6 +?????#?#?? 6,1 +??#?#?.??????#?.??? 6,2,1,2,1,1 +????????#????##.?#?. 1,11,1 +?.?#?????? 1,2,1 +??????##??.??????. 1,1,4,4 +??##???##???#.#?.?.# 11,1,1,1,1 +?.?.??#??..??##?#. 1,2,6 +#???##??????? 2,3,1,1 +#?..????#??#.?### 2,2,3,1,4 +??#???#??????#.????? 12,3 +?#?#??.#?? 4,2 +??????#??.???..?#?# 7,2,3 +.???#?..?????#?.. 5,1,1 +?.?????..?????. 2,1,1 +??#??.??##???.????. 2,6,2 +.????????.#?? 1,6,1,1 +.???????##???? 8,1 +.??##?.?????#?? 2,4 +.??????#????###?. 1,4,6 +?#?..###??#???##?? 3,4,1,3,1 +??????????##?????. 2,3 +???#????#?#?# 1,6,1,1 +#?##?????#????#???#? 5,1,1,9 +#???#?#?#????????? 1,1,7,1,2 +???..#?.?#?#.#?#??? 1,2,4,3,1 +?#.???#???##?#??. 1,1,6 +????##?#?#?.?.? 2,3,3,1 +??????##???? 1,9 +??###???.?#?? 5,1,2 +#.#?.??.#? 1,2,2 +?.??????.?.????.?... 2,2 +????#??????.? 6,2,1 +?????.?????#?.#??? 1,2,7,1,1 +.?#?#???????? 3,2 +.?????#?.?.?#????? 6,5 +#?#??..??##??. 1,2,1,4 +.???#..??#?#? 3,5 +???#????#?.???##???? 10,1,4,1 +?.?#?.??..???? 1,2,2 +???#??.?#?.??? 6,1,2 +.????#???##???????? 6,3,4 +#???#?.???????###?? 1,1,1,1,1,6 +??#???.?.?.??#?? 3,1,1,4 +?.??##?????.?.?#?. 1,9,2 +??????.??#???#.#.. 4,6,1 +??##??.??# 4,1 +.?#???.#???#?## 3,1,1,1,2 +???#???##???#. 3,6,1 +#????..???#. 3,1,2,1 +#.??#??#??#?? 1,2,1,1 +?.##???#?. 1,2,3 +?????????#????.?. 14,1 +??##???#???.??# 8,1,2 +..?#???#?.????. 2,3,1,1 +?.??????.???#??.. 1,1,5 +??..#???#????## 2,5,2 +????#?#???#?#??#? 2,2,8,1 +????????#??????? 1,3,7 +#?#?###???#?? 1,9 +????.????.?#????#?# 4,1,2,4 +??#.?#?#????? 3,2,2,2 +#??#??.?.?#?#??#??? 6,1,6 +.#??.??????? 3,2,1,1 +??.#?#.????.??? 3,4,1 +??..#?.?#.?#???? 1,2,1,1,2 +??#??#?????#?.??? 3,4,1,1,1 +.??.???#???..?? 1,5,1 +??.????..??.#???#? 1,3,1,1,2 +????###???#???? 1,9,1 +.?##????.?##? 4,1,4 +?.?.???.#?#?? 2,4 +..??#???#??.#. 8,1 +?????????#? 4,1 +?????#???.??# 6,1,3 +.????.????#. 1,1,2 +??.????##?? 1,6 +?.#??.?????#?## 1,3,1,6 +??#????????#.???#??# 5,1,1,2,4,1 +?#..?#.?#? 2,1,1 +?..?#?#?#?#??#???? 10,1 +?#?.???.?????? 1,1,1,4 +?.?.??#?.????.??. 3,2,1 +??#?#####???#?????.. 10,1,1,1 +.???#?????#??? 2,3 +#??#???.?????? 1,2,1,2 +#.#.?.???#??? 1,1,1,6 +..???????. 5,1 +?#?????#.?#???##?##? 5,2,3,6 +??#??#???#.??#?#?. 1,8,6 +?#??..??.. 2,2 +?.##???.###? 2,1,3 +????..??????#? 1,1,5 +?.????????.???.?? 5,2 +??.?..???????? 1,2,3 +.?.##?.?.?. 3,1 +??????#??.????.? 6,1,1,1,1 +..???#??#..#??##?? 4,7 +?#??#?#.#????.????# 4,1,3,5 +.??.????.? 1,3 +?#?.??????#??##? 2,1,3,5 +??##.???????#.??? 3,2,5,1 +??.???????#???#? 1,1,1,3,1 +?????..???? 2,1,1 +?.????.?.??#?????? 3,4,1 +#?#?.?..#?????????#? 3,1,1,9 +???.?#???#. 2,1,1 +?#???#??#?????#???# 2,11,1 +?#.??#????#??? 2,1,3 +##?.?##??.? 3,4 +???#?#???..?#??? 5,2,1,1 +.#????.#?#??#??? 3,6 +..#??#???? 1,2,1 +#??.???#?##.?# 1,7,1 +??.???.???????.??? 1,1,1,3,1,2 +.??.?.????.#???.?#?# 1,1,3,4,1,1 +.???????##?.? 5,2,1 +?.??????#?? 1,3 +???.#???????# 1,1,5 +???#??#.#???? 1,1,1,2 +??.???.???????#??? 1,1,1,1,6 +.???#?.???##? 4,4 +???.???##?##???.???? 10,1 +??###???#??????#.?? 5,5,1,1 +?#??????#?#?.??? 2,8,1 +?###??#???????#. 9,1,1 +.???????#?###??? 1,1,1,6 +?.?????##??#??#?? 1,13 +???????##???.??#??? 11,2 +.???#?#?.??.?? 6,2 +?????????#####?#.? 1,11,1,1 +??#??.?????##?#???? 1,1,1,5,4 +?#??##?.???# 2,2,4 +#.?????#?????? 1,1,5,1 +.#??????##.? 3,1,2 +???##???..??##.??. 6,3,2 +??.??.#?#????.?????. 1,2,5,1,3,1 +?..##?????.#??##?## 1,3,1,8 +?.????#???.??? 1,4,2 +.???#?.?.?.? 4,1,1 +.??##??#?#?????#??#? 14,1 +.?#???..???????#?? 4,1,6,1 +???#??.?????..#???#? 2,1,4,6 +???.#???##?#?.?.#. 1,1,3,5,1,1 +???..??#?#?????????. 1,3,10 +???????#??.??#?#?? 3,1,1,3,1 +??.?.????. 1,1,1 +??.??.#??#? 2,1,2 +??#????#??#??# 4,8 +?#???#???#???? 2,7 +???#??##?????? 1,7,2 +??????.??##??????#. 2,11 +?#???##???##? 3,8 +.?#?..???.??????##? 2,2,8 +??.?##?..#?###?...? 3,6 +???##???#????? 11,1 +.#???#????#?#?????? 1,1,14 +?.????#?.???######?? 3,8 +?.??????###????.? 2,9 +?.#.????.???.? 1,3,1,1 +????.??..?# 2,1,2 +??.?????.????#? 1,2,2,5 +?#????????# 5,3 +.??##????????? 4,3 +#????????? 2,1,1 +.???#??#???#?...? 9,1 +.??#?.?.##?.? 2,3 +??.?#??#???? 1,2 +.#????????????. 4,2,4 +?.????????????#? 1,1,6,2 +???#.??#??? 2,2 +?..#????#??#? 1,1,4 +#???###??..?.# 9,1,1 +?#?#??????? 3,1,2 +???.??????#? 1,1,2 +.#????????#. 2,1,1,1 +??..?#?.#?????#.?#? 1,2,7,1 +.??#..#???? 2,4 +?#??????..? 2,2,1 +?#??#?.???????? 3,1,3,1,1 +?#??#?#?????#??..?. 7,3 +??.#.?.#??##??#?#. 1,1,1,5,1,1 +?#.????.?? 2,1,1 +??#?.???#???. 3,4 +...???.??????#.#?#? 3,7,4 +..??#?#????.???? 6,1 +#??#?.#??#??####?. 1,1,1,8 +????#.#?#?.??#.. 4,1,1,2 +?????#?#??#?? 4,6 +.????#???.?????.???? 1,4,1,1,1,4 +.???#????? 1,1,2 +???.??????. 2,5 +#?#???#??##??. 11,1 +?.?????.?# 2,2 +.?????????#????????? 8,3,5 +??????#??#?#? 8,1,1 +##?????#?. 2,1,3 +?????###?.??????? 7,2 +??#?????.?#?.????? 1,6,1,5 +.?..????#????#.???? 9,1 +??.?????#.?.?? 1,1,1,1 +??.????..#??.. 1,2 +.?#.#?#?##???# 2,1,5,1 +??..???#?????.?? 1,1,1,3,1 +?#?#??#?#??????????. 2,9,1,2 +???#?????.#..??#???? 8,1,4 +.??.???#?????. 1,1,3,1 +?????.#??# 2,1,1 +.??#.????. 2,3 +.##?????.?# 2,2,2 +?#????#??#??????? 1,11 +????????#??????.?.?? 8,1 +??#?#?#??###?##???#? 13,1 +??#.??#???#? 1,1,2,4 +???##.???????. 1,2,2,4 +?#?.?????.??#.? 3,1,3,1 +????.???..#?? 2,2,2 +???..??????..?.?#?# 2,2,1,4 +??????#??#.??#??.. 4,2,4 +????#.???#???.?#??? 5,6,2,1 +??#??.???? 3,1 +??..#????###?????# 2,2,1,7,1 +?##??#??#??# 5,3,1 +???#???.???.#?#? 4,1,1,2 +.????##.?.?#??? 6,1,1,1 +?.??.#.?.?.# 1,1,1,1 +?..????..? 1,1,1 +??.??.???# 1,1,4 +.?#???????? 2,2 +?##.???..?# 3,1,1 +??#??#????. 2,3 +????##???#?.?.#?? 9,2 +#.?.##?#.??? 1,2,1,2 +?#??#??#??#.?? 7,1,1 +???.##?.???.?#??#? 2,3,3,1,1 +??#?.###???#??# 1,1,10 +?##?.????.?? 3,1,1,1 +??????.?????#????.?# 2,1,2,3,1,1 +?#??.???###.# 1,1,3,1 +????.????. 1,1 +?#???.?????? 2,5 +?????#???????? 1,5,1 +????????..???????? 1,1,1,1,4 +.#?????#?????? 9,1 +?????#?.?#??#?? 1,2,3,2 +???#????.?#.? 5,1,1 +#???##?#?.?.?.????# 1,7,1,1,1,1 +??.??#?????.???? 1,5,1,1,1 +?.????#??????#? 1,1,2,5 +..??????.. 2,2 +.????#???.??#???#? 7,5 +?#?.?##??????.??#? 2,2,3,1,1 +???.?#?????? 2,6 +?#?#?#.?????.??. 6,1,1,1 +?.??##..???#?##??? 3,7 +?#????#?#??..? 2,5 +??#???#??#??.?? 3,6 +?.??????#?###???.?? 1,1,6,2,1 +???????????#??? 3,2,2,1 +#???..????.#.#?? 1,1,1,1,3 +#?.?????.#? 2,1,2 +.??.????#?? 2,3 +#..????????????.? 1,4,5 +#.??.#????#??##?.? 1,1,4,1,4 +??#?..??.?? 4,1,1 +??#.?#????????? 1,1,5,1,2 +.??????#?##???.?? 1,5,1 +?#.#??...?#???#? 2,1,1,4,2 +#??#?????..# 1,4,1,1 +?#.???..?? 1,2,1 +?##??..?##???.#.? 4,5,1 +??#???..#. 5,1 +?.???.#??#.???.? 1,1,1,1,3 +.???.??##?#?. 3,3,2 +??.#.?..?? 1,2 +.?#??#???# 6,1 +##????#.??# 7,2 +##??.???.?##? 4,1,3 +???#?#?..??????# 1,4,1,1,1 +??.???????.?##??? 1,3,3,6 +.?#?#????#??#??? 4,4 +??.?#?????..???# 4,4 +.??.??.???#. 1,1,1,1 +.?????.???????? 3,8 +?..?#..?##?.??? 1,1,3,2 +???.#??..???. 2,2,2 +????????.?.?#??.? 3,1 +??##?.????#? 5,1,2 +.???#.???. 4,1 +?#??.?.?.?##?? 2,1,5 +?#?###.#???????#.# 6,2,3,1,1 +??????.??#??.?### 1,4,3,3 +??????#??..????. 5,3 +???????#??..??? 8,1 +??#???#????#?#??.??. 14,1 +??#..??????#??##?? 1,1,9 +?##??#??.#?????##.?. 7,2,4,1 +.?##????.#. 3,1,1 +?.????.#?##?#. 1,1,2,1 +?#?#..????#.? 3,2,1,1 +????#?###?..##?? 1,1,4,2 +?#..???????? 1,1,1,2 +???????#????? 6,1,1,1 +????.#??#?.. 3,1,2 +.#?.?????#???#? 1,1,7 +?#??##???#.??? 7,1,1 +??..????#? 1,2,1 +.?#???????? 3,1,1 +???.????.?.??? 1,3 +???????#????.? 4,5,1 +.????????#.??#?????? 1,1,1,1,5,1 +????#?????#?#??##?? 4,9 +???.?.#?????? 2,3,2 +?#???.#.??..? 1,1,1,2 +????#??????????#. 9,2 +???.????#..?##. 1,4,3 +????.??.????.?? 1,2,1,3,1 +?###????#????#?## 4,4,4 +??#????????#?? 1,3,1,5 +??#?????#??###..?? 14,1 +????#.?#.??.?### 2,1,2,1,3 +?.?.#?.?#? 1,2,3 +#????????###..?.. 4,2,4,1 +#????.??##?##?# 1,2,1,7 +???????.??.??? 5,2 +?#?.##????.?#. 3,2,2,1 +?#?#??#??#??.? 7,4 +??.???#????. 1,7 +?.?#.????##?????.# 1,7,1,1 +????##????? 8,1 +??????????##???#?? 3,12 +...##..??#???#? 2,6 +?#?????.??. 2,1 +???.?????. 2,1 +.?##???????##???. 3,2,2,2 +??.????.?..#?.... 4,2 +?##????????##???.# 4,1,6,1 +??#??????#?#?? 1,8 +???.#?????#??.??? 2,9,1 +.##?.??..????# 3,1,1,3 +?#?.?#???#?.???? 2,6,1 +?.?????.????#? 4,2,1 +##?##?.????##?.? 5,7,1 +???????????.# 2,1,1,1 +#???#???.#.???# 1,6,1,1,1 +??????##???.?.?# 8,1,1 +?#???###.??? 2,4 +#?.#?????.?#.???..# 1,1,4,1,3,1 +?????#.?.??#?# 1,1,5 +??#????????.???#??? 5,3,2,1 +.????.??##..???? 3,3 +.#.????#??#??? 1,8,1 +..???#???????.. 4,4 +.?#?.??#?????.?????? 3,3,3,2 +?????????#? 5,2 +#.????#.????##?.#? 1,2,2,6,2 +??#?#.?.#? 3,1 +??#??????#??.?? 3,3 +..???..???? 1,1 +???.##?.???? 2,3,1,2 +??????#?#?.### 7,3 +?????..??????.#??#? 3,1,1,1,2,1 +?#?#??..????#??. 3,5 +#.?.#????#?? 1,2,2 +.???#...?# 2,1 +.???.???#???????.?? 1,1,1,5,1,1 +??#??#???#?..? 5,3 +#??????##?? 3,5 +#??#.?#???####??#??? 1,2,2,1,5,2 +???#?????.?????????# 5,1,1,1,1,1 +?#?????#??? 1,1,2 +???#?#?.??#???? 2,4,6 +#?????.?????? 1,4,1,2 +???#???#?????.?? 11,1,1 +##??????????#.? 3,1,5 +#.???????#???.???. 1,1,2,1,4,1 +?#???..###? 2,3 +?#?.??????? 2,1,1 +???.?#?#?? 2,2,3 +??#?##??..#? 1,4,1,2 +?#####.????????#? 5,9 +?.??.?####????? 1,1,8 +???..#????????##. 1,11 +?.??????????#????#? 11,4 +.?#???#?????##?. 2,2,1,2 +.???????.# 1,2,1 +.???#????#???#? 3,9 +..?.??.##??#. 1,5 +??.#???##?##?????# 1,1,13 +?##???.???? 5,3 +??.#?????.??? 1,2,1,1 +?.?#?#???#.???#??#. 1,4,1,1,1,1 +#?.????#?..#??? 2,1,3,1,1 +??#??##??? 4,4 +.????.?.??## 3,4 +?.?????.?#???? 1,4,2,3 +.??????????. 2,1,1,1 +?#?????..#?##? 1,1,1,3 +???.?????..#? 1,1,1,2 +????#??????.#?#.? 1,2,4,1,1 +??#?.?#???#?#??#?? 1,1,2,4,1 +??????????#?# 6,5 +????#?#?#? 2,5 +.##??.#?????.#? 2,1,1,3,2 +#????.???#? 5,1 +?????##????#.??#?# 4,2,5 +.?????#????# 2,1,3 +.??.#?????? 3,2 +????##???.?.???? 5,1,1,1,1 +.?##?????#?. 2,4 +?.????.??#???.?. 4,4,1 +??##??#??..?? 5,1 +?#???#?#?.?.#??#?? 1,6,1,2 +???????#????#.?# 9,1 +#??.??#?#??. 3,7 +##??????#.?# 2,4,1,1 +#??#?#??#???#??#. 6,7,1 +??????????.? 2,2,2 +??#???.???#?#?#???? 2,1,4,1,2,1 +..?.#.#??.?# 1,1,1,1 +.###?#.###.? 5,3,1 +????###?#??.#. 1,6,1 +?.?#?#??##?????##?# 1,4,11 +.??????#?????.# 1,1,5,1,1 +.???????##??#.??. 12,1 +??????????? 3,1 +..???#?##?#?#??? 2,2,5 +?????.???? 1,2,1 +???#??##???.???#? 11,1,2 +??????#??? 1,3 +??#?????#? 4,1 +.?#???.?#?##??? 4,2,5 +?#????#????.?#?#?#?? 1,3,1,2,1,3 +?....?#????#??????.? 4,4 +?#?#.????????##?? 2,1,5,2 +.???#??..?? 4,1 +????#??.????#? 2,3,1,3 +???####?.?#???##? 5,1,2 +??#.#???????? 2,1,1,1 +.?#???.???.??#?? 2,1,3,2 +???#?#???####???? 4,1,9 +??..?????###????#?. 1,11 +..???????#?#???..?#. 13,2 +.?#?##?????????.??? 5,4,1,1,1 +?????.???.#????????? 3,1,3,4,2,1 +?????????#???#? 1,5,4 +??#???##.?. 3,3 +????#.???#?##?#?.?.. 1,1,1,1,8,1 +??#??#?##????#???.?? 12,2 +??#????#??# 7,1 +?.?#????????? 1,4 +????#...?????#?? 4,2,2 +???#????..?#? 6,2 +???.?#?##??????????? 3,5,3,4 +?##???#??..?#.#?? 2,1,3,2,2 +?##??????.#. 9,1 +.?#????###.???? 8,1 +???#?###????.? 4,3,1,1 +?.????#???????????? 1,1,1,2,6,1 +??##.??.?#.??#???#?? 4,2,1,2,3 +???#??#?.?.?#??##?? 6,7 +??#???##??#.?.?.?.#? 8,1,1,1,1,1 +.#?????#?? 1,6 +?#?.??.#?? 2,1,3 +.??#?#?????#..#??. 1,1,1,5,3 +?#.???.????#??. 2,1,3,1 +..#?????.?.?# 4,1,1 +??#??????#??#??? 3,7,1 +?????????????##? 3,8 +?.???#??????#.#??. 1,3,4,3 +?#.#????#????? 2,4,5 +????????????.? 2,1,3,2 +.???#??#??.? 3,3 +?????.??#?? 2,1 +?????????????#???? 2,11 +?.??#??#?.?.????? 5,1,1,2 +?##?..#???????.? 2,1,2,1,1 +??????..???.? 4,3 +.#???#?#?##??????? 1,1,7,2,1 +??##?????#?.???#. 6,4,2,1 +??????.?..#????#? 1,4,1,1,5 +?##.????#??. 2,5 +.??????#.?. 1,3,1 +?.##?????..? 1,4,1 +?????????#? 1,2,1 +???.??#??? 1,1,2 +????????#.? 8,1 +.????#???..#?? 6,2 +??????.#?.?.?#?? 1,2,1,3 +???#?#??.?????????. 6,7 +???###?..??#???? 3,6 +...???#?????.?#?. 8,2 +?#?.???#?.?.? 2,3,1,1 +#?#?#????.#???? 6,2,2,1 +?#?????##?.??#?#?.?? 9,1,1,1,1 +??????????#?#? 1,1,1,3 +#????.??.?#??. 5,1,2 +???..#??????### 1,1,1,2,3 +???#.#?##??##?##? 3,1,3,6 +???????..?? 4,2 +?#???..#??#? 1,1,1,1 +?..?#?#.?.#??#?? 2,1,1,3 +#??#?????#????.?? 4,3,2,1 +??#?????.?#.? 5,1,1 +.?#??.#???#?????#?? 4,1,1,1,1,1 +?????????#? 2,4 +..?.?#??#?#??.??? 9,1 +.??.??##?. 1,5 +..??#????.?..??? 6,1 +?#????.????#? 4,1,1,3 +?#??.??#?#????# 2,1,8 +?#.?.#.#??#??#?#?## 1,1,1,12 +.??#???????. 2,2,2 +??.##?.??#? 1,2,4 +???????### 1,1,5 +.?.?##????? 4,1 +??.#??.?#..#.?????? 1,2,2,1,2,1 +?#?#??????#?##?? 8,1,2,1 +??#?.??.#. 3,1 +?#???#?.?.??.?#..?#? 7,1,1,1,2 +.?????.##.. 2,2 +??.?????.??.#?#??. 1,3 +?#?.#??#?..?? 2,4,1 +??##?#??#?#?. 5,3 +???#....????. 4,3 +#?.#????#?#?#?# 1,1,3,1,1 +#.#??#?.#.?????## 1,1,1,1,7 +?.??????#??#???#?#? 1,1,1,12 +?.?.????#???. 1,3,4 +.?..??##??..??.??? 1,6,2,1 +?#????????#??? 3,2,4,1 +??.????#?###??? 2,7 +..?#?????#? 2,1 +?..??????.#?..? 1,6,2 +?.#.?.????? 1,1,3 +???#???????????#?#?? 2,3,7,1,2 +?##??#????##?..#???. 12,1,1 +?????????.#?????. 5,2,1,1,1 +??#?#?.??##?#??? 3,1,3,1,1 +???#?????????. 3,5 +?#?#?##????.?#?? 8,1,1 +?.???#?.?.? 5,1 +???.#.?#????????.. 1,1,9 +#?.???..?????#?.# 1,3,2,2,1 +??##?.?.???##???? 3,6 +??#??#???? 2,2 +#????#?#.. 4,3 +?#???????????? 2,5 +#??????...??#??#???? 1,2,2,1,2,5 +.?#?#.????#.??.? 3,1,2,1 +??#?#??.?#????? 5,1,1 +????????.?#? 1,1,1,1 +???????#?##?#?????#. 1,1,9,1 +?##?.?????? 2,3 +??##???#????#?.?# 11,1,1 +??##?#?##?????#?? 8,4 +##??#????#?#.?? 2,1,1,1,1 +#????????#????#??.? 4,5,2,1 +???#???##???#?.?? 2,6 +?#?.??#?????...#?. 2,7,2 +????..?###????#?? 2,4,2 +??#??????#??. 2,2,1,1 +????#.?.#?.#????? 1,2,2,2,1 +.#????#???# 3,5 +.#?##???#??#?.# 9,2,1 +????##??.#.? 4,1 +#.?????####??.?.???. 1,11,1,1 +?#??????#? 2,1,2 +??#?.?..?? 2,1 +??.#??.?.? 1,1,1 +?##??#.?#? 4,1,1 +?#?######.?.## 8,1,2 +?..#??#.?#?#?.#?? 1,1,1,4,1 +????#??.??##?????#?? 1,5,8 +??.???????? 2,1,2 +???##?????????#.?#?? 7,7,1,1 +.?.?????#???. 3,1,2 +?#?????????????#### 1,1,1,1,2,4 +??#?.????### 3,2,3 +?##?.????##???? 3,4,1 +#????????? 2,3 +?.??#???.??##? 1,5,1,2 +???##???###??.??.? 1,10,1 +???#?????? 2,4 +.##????????? 4,2 +.?.????#?#? 2,4 +???.???#???????#???? 1,11 +.?#??.??##? 1,3 +????.??????????#..? 2,7 +??#?.#??.?#???##??#? 1,1,1,8,2 +?#?.????.?#??? 2,2,2 +????????????????.?#? 5,1,1,2 +#?#.?.???????#?#??? 1,1,1,10 +.?#??#.?????###?? 3,1,1,5 +?.?#?????#?#???? 1,2,1,5,1 +??#???.###??..??.? 3,5,2 +?##?#????.????#??#?? 7,8 +?.?..????#????? 1,1,1,1,3 +??#?##?...???#????? 5,4,1 +????##???##?. 1,8 +??.?#?#?.?.????? 1,5,3,1 +?????.????..??. 2,2,1 +.??.??????? 1,2,3 +..#?#??????#???? 11,1 +?..?.???#??.?#??. 6,2 +????.#?????????#???? 2,1,11,1 +??#????????.??.?.?? 1,7,1,1,1,1 +???????????.? 5,2 +??????.?##?. 4,4 +.???.???#.? 1,3 +??.?###????#??????#? 2,15 +?#????##?? 3,3 +??.????????????#? 2,2,1,1,2 +?.?#.????.?. 2,4 +?.#???#??? 1,2,2 +???.?.?#.. 3,1 +?#???????????????? 4,1,1,1,2,1 +.???#?????##.? 3,2,2,1 +??#?.##..#??? 1,1,2,3 +#?.?###????#?.?? 1,9,1 +..#??##?##?? 1,2,3 +???#???##.??#???? 8,5 +.???????#??????????? 2,1,3,1,5 +?#?#???#.??#?????#?? 3,1,2,5 +?????????#??#??#. 1,3,1,5,1 +??.#??###?.?.?. 1,7,1 +?##????..?.??.. 6,1 +#???#?#??????#??.? 7,1,1,3 +?.????#??#???.??.?# 10,2 +??.?#?????#?##??.? 2,13 +?#??#???#?#?#.?????? 12,2 +?#??#????????? 3,6,1 +??????????#?#?##?## 2,1,11 +.?#.???????#?#???? 2,11 +..?#????##??.. 4,3 +???????#????? 1,1,4,1 +???#..#?#?? 1,1,5 +.?..?.#???? 1,4 +????#???#?????#?? 6,1,3,1,1 +??..?.???.?? 1,1 +?#???.#??#????.? 2,1,1,2,1 +?#?..##??#?? 2,5 +????.??##?#??.? 1,5 +??????.#?###.?? 1,1,1,3,1 +?##??.?#?????? 5,2,4 +????????????????.? 2,1 +?#???#?????#???#?# 3,2,3,3 +.????#???.??.# 1,3,1,1 +???????????? 5,1 +.?.#???????? 2,1,2 +??#???.??????#?. 3,1,1,6 +??.?#???.##??#?# 1,3,7 +?..???#??#?????. 7,2 +???.?.????#??#. 3,1,5 +?.????##??##.?.??#?? 1,1,3,3,1,3 +?????#???.#??#?#? 3,1,2,2,4 +#.???????.???#??? 1,1,1,1,2 +#?#?.????.?? 1,2,2,2 +#????.?#.#?.??.? 5,1,2,1,1 +?#??.???#?#.#?.?? 2,6,1,1 +??????#??.?.#?. 1,1,3,1,2 +??.?...#??. 1,1,2 +.#?.?.??.?.??#.???? 1,1,1,1,2,3 +.#..??##?.? 1,4,1 +???#????#?#.??. 1,3,1,1,1 +??#??.?#??? 4,1 +?.??##??.??. 5,1 +??#???..??????? 3,1,1 +#.???##????#?? 1,4,4 +.#??#?#??.?#???? 2,4,6 +????????##????? 2,2,7 +?????#?#.??? 1,1,3,1 +??.#????##?#???..#?. 1,11,1 +???#?#???????????? 3,9 +?#.#??#?.?#??? 2,1,1,5 +??.??.???? 2,2 +?????#?#??##? 8,3 +?????.????#?#???? 2,1,6 +?.???#?????.???? 1,1,7,1,1 +.?.????####??#??? 1,1,1,7,1 +???.???.????? 2,1 +????.????? 2,4 +??#?..????.. 2,1 +?#?#.?##?. 1,1,4 +..######????????#?? 6,6 +?#.???###?????? 2,8,1 +?#????##?.???#???? 8,1,4 +??????.?.#????#?#? 5,1,8 +????#?#????.#???.? 1,1,2,1,3,1 +.?????#?#???..?? 5,1 +?????##??????##?##. 6,10 +????#???#???#??# 5,1,5,1 +??????#?????#?#?.?? 13,1 +??#???#?????? 4,1,1,1 +?.?.?????#??#?? 1,5,2,1 +?#.???.??.?#??.?. 1,1,1,2,1 +?????##????? 6,1,1 +?.##??#####??.???? 1,11,1,1 +????#?????. 3,2 +??????#.??#??? 2,1,3 +#?.?.???.??##???# 2,3,4,1 +.????#.??#???..????? 5,4,3 +.????.?.#????..?? 2,1,2,1,2 +?..??#...#?##.? 3,4 +#.?????#.?.???#??#. 1,5,1,7 +.?#??##???? 5,1 +?.?????#??#? 1,3,1,2 +??#???.??.?#???? 2,1,1 +.?#?.?.?##?????# 1,1,5,1 +??#.???.?###??? 2,2,6 +????????.???? 1,2,1,2 +#?????.?.?#???. 1,4,4 +?.??.?#???# 1,1 +..????????#???????? 10,3 +??#???.?.???. 2,1,1,1 +??#?#???#?????? 10,1 +??#?#??#??????. 5,7 +??#??????? 2,1,2 +?????##?????.. 1,4 +.?#??.??.#?#?#. 3,1,3,1 +?.?????..? 1,1,1 +.????.??#?.?###???? 2,1,2,6 +.##???.??.###?????# 3,1,1,4,1,1 +?..?#??##???#?#??? 3,10 +??????##?#??#?? 4,9 +?####?.????###?????? 5,8,1,1 +?????????? 1,1,1 +??.?????.??#??????# 1,1,1,2,1,3 +#?.##??.##. 1,3,2 +????.?#?????# 1,1,1,3 +??.?#.#??..##???. 2,1,2,5 +??????????.?#??#???# 1,1,1,1,6,1 +???#???#?#??#???. 9,2,1 +?#???????????? 8,1,1 +#?.?.????????#??###? 1,1,12 +#??##???#? 5,1,1 +?????.?#??????. 1,1,4,1 +??#.#?#?.#?.????## 1,1,2,1,6 +?.?????.#. 1,1,1 +?????#????#?#??.#? 1,1,8,1,1 +??##?.??###?.??? 1,2,1,4,1 +?????#???#??..???.? 2,8,1,1 +#.#.??.?.??.???#? 1,1,1,1,4 +?????.#?.?.?? 1,1,1,1 +.??#??#?.##???###? 7,8 +?????????##??###?.? 3,11,1 +???#?.??#???.??.? 3,4,2,1 +?#??#??#??..?..?? 9,1,1 +.#???????#????? 1,1,1,5,1 +?????????..???????# 2,2,1,1,5 +?##?.??#??? 3,5 +#??#??##?? 1,3,3 +.?.?.??????##?#???? 1,2,7,1 +??#?????##?#??.??? 2,5,3,1 +???.....#?.?? 1,2 +?#?.#??#???? 1,6 +??#.??#?#??#??? 2,4,3 +?.#?#??#.???# 6,1,1 +.??????#???.#.??##.. 8,1,4 +??.???#?.##???#? 1,1,2,7 +????#??#????????# 5,6,1,1 +??#?.?#.#???#?? 3,2,2,3 +.#.?#?##.#..?????? 1,1,2,1,1,3 +??##.??...??. 4,1,1 +#??#???.?#??? 2,1,1,5 +?#???#?.?? 6,1 +#??.#???????.?.? 2,5,1,1 +??#?#.???#??.?? 1,1,1,5,2 +????#????.?. 1,7,1 +?.?#.?.?#?. 2,2 +..??..?????.?.##??? 1,5,3 +?#?..#?##? 2,4 +????..#????????#?#.? 3,12 +???.??????#?????#?? 9,2 +????????.# 3,1 +??????#???#? 3,3,2 +?#???#????.??# 3,4,1 +.?????????# 3,1,1 +?.??#.??????#??? 1,1,1,5 +.???..?#.??? 3,1,1 +#?..??.?.??????# 1,2,1,2,2 +?????????? 5,3 +??#.??????#. 1,1,7 +..???.?????? 2,1 +?#????#?#???????#? 4,5,5 +??????????#?####?##? 2,15 +???.?????? 1,3 +?#.####?#?#??#..# 2,4,4,1,1 +????#???#.?.?.? 6,1,1,1 +??#?#?????.. 3,2,1 +####?????####.#????? 13,1,1 +????#?????.??.#.?# 1,2,1,2,1,2 +#.?????#???. 1,2,3,1 +???#????????.???#?# 10,5 +#???????##? 4,3 +?#????.????..???#. 6,3,2 +..#?##?.?.. 4,1 +?#??.#?#??? 1,3,1 diff --git a/2023/day12/src/main.rs b/2023/day12/src/main.rs new file mode 100644 index 0000000..d8fd837 --- /dev/null +++ b/2023/day12/src/main.rs @@ -0,0 +1,245 @@ +// Problem: https://adventofcode.com/2023/day/12 + +type Result = usize; + +type Input = Vec<(Vec, Vec)>; + +fn parse_row(s: &str) -> (Vec, Vec) { + let (a, b) = s.split_once(' ').unwrap(); + ( + a.chars().collect::>(), + b.split(',').map(|s| s.parse::().unwrap()).collect(), + ) +} + +fn parse_input(input: &str) -> Input { + input.lines().map(parse_row).collect() +} + +fn is_valid(springs: &Vec, groups: &[usize]) -> bool { + let mut it = groups.iter(); + let mut cur: i32 = -1; + for s in springs { + match *s { + '#' => { + if cur == -1 { + if let Some(next) = it.next() { + cur = *next as i32 - 1; + } else { + return false; + } + } else { + cur -= 1; + } + } + '.' => { + if cur == 0 { + cur = -1; + } + if cur != -1 { + return false; + } + } + _ => { + panic!() + } + } + } + (cur == 0 || cur == -1) && it.next().is_none() +} + +#[test] +fn test_is_valid() { + assert!(is_valid(&"##.#".chars().collect(), &[2, 1])); + assert!(is_valid(&".###.##.#...".chars().collect(), &[3, 2, 1])); + assert!(!is_valid(&"###.".chars().collect(), &[2, 1])); + assert!(!is_valid(&"####......##".chars().collect(), &[3, 2, 1])); +} + +use std::collections::{ + btree_set::{BTreeSet, IntoIter}, + HashMap, +}; + +enum UniquePermutations { + Leaf { + elements: Option>, + }, + Stem { + elements: Vec, + unique_elements: IntoIter, + first_element: char, + inner: Box, + }, +} +impl UniquePermutations { + fn new(elements: Vec) -> Self { + if elements.len() == 1 { + let elements = Some(elements); + Self::Leaf { elements } + } else { + let mut unique_elements = elements + .clone() + .into_iter() + .collect::>() + .into_iter(); + let (first_element, inner) = + Self::next_level(&mut unique_elements, elements.clone()).unwrap(); + Self::Stem { + elements, + unique_elements, + first_element, + inner, + } + } + } + fn next_level( + mut unique_elements: impl Iterator, + elements: Vec, + ) -> Option<(char, Box)> { + let first_element = unique_elements.next()?; + let mut remaining_elements = elements; + if let Some(idx) = remaining_elements.iter().position(|&i| i == first_element) { + remaining_elements.remove(idx); + } + let inner = Box::new(Self::new(remaining_elements)); + Some((first_element, inner)) + } +} + +impl Iterator for UniquePermutations { + type Item = Vec; + fn next(&mut self) -> Option { + match self { + Self::Leaf { elements } => elements.take(), + Self::Stem { + elements, + unique_elements, + first_element, + inner, + } => loop { + match inner.next() { + Some(mut v) => { + v.insert(0, *first_element); + return Some(v); + } + None => { + let (next_fe, next_i) = + Self::next_level(&mut *unique_elements, elements.clone())?; + *first_element = next_fe; + *inner = next_i; + } + } + }, + } + } +} + +fn arrangements(springs: &[char], groups: &[usize]) -> usize { + let wildcards = springs.iter().filter(|s| **s == '?').count(); + let total_operational: usize = groups.iter().sum(); + let have_operational: usize = springs.iter().filter(|s| **s == '#').count(); + let need_op = total_operational - have_operational; + let mut a = (0..need_op).map(|_| '#').collect::>(); + let mut b = (0..(wildcards - need_op)) + .map(|_| '.') + .collect::>(); + a.append(&mut b); + UniquePermutations::new(a) + .map(|c| { + let mut it = c.iter(); + springs + .iter() + .map(|s| if s == &'?' { *it.next().unwrap() } else { *s }) + .collect::>() + }) + .filter(|s| is_valid(s, groups)) + .count() +} + +fn part1(input: &Input) -> Result { + input.iter().map(|(s, g)| arrangements(s, g)).sum() +} + +#[test] +fn test_part1() { + let input = parse_input(include_str!("test.txt")); + assert_eq!(part1(&input), 10); +} + +// ------------------------------------------ + +fn find_arrangements( + pos: usize, + group: usize, + group_pos: usize, + springs: &Vec, + groups: &Vec, + cache: &mut HashMap<(usize, usize, usize), usize>, +) -> usize { + if let Some(res) = cache.get(&(pos, group, group_pos)) { + return *res; + } + if pos < springs.len() { + let mut res = 0; + if springs[pos] == '#' || springs[pos] == '?' { + res += find_arrangements(pos + 1, group, group_pos + 1, springs, groups, cache) + } + if springs[pos] == '.' || springs[pos] == '?' { + if group_pos == 0 { + res += find_arrangements(pos + 1, group, 0, springs, groups, cache); + } else if group_pos > 0 && group < groups.len() && groups[group] == group_pos { + res += find_arrangements(pos + 1, group + 1, 0, springs, groups, cache); + } + } + cache.insert((pos, group, group_pos), res); + return res; + } + + if (group == groups.len() - 1 && groups[group] == group_pos) + || (group == groups.len() && group_pos == 0) + { + 1 + } else { + 0 + } +} + +fn fivex(list: &Vec, delim: &Vec) -> Vec { + let mut result = vec![]; + for i in 0..5 { + for v in list { + result.push(v.clone()); + } + if i != 4 { + for d in delim { + result.push(d.clone()); + } + } + } + result +} + +fn part2(input: &Input) -> Result { + input + .iter() + .map(|(s, g)| (fivex(s, &vec!['?']), fivex(g, &vec![]))) + .map(|(s, g)| find_arrangements(0, 0, 0, &s, &g, &mut HashMap::new())) + .sum() +} + +#[test] +fn test_part2() { + assert_eq!(part2(&vec![parse_row("???.### 1,1,3")]), 1); + assert_eq!(part2(&vec![parse_row(".??..??...?##. 1,1,3")]), 16384); + assert_eq!(part2(&vec![parse_row("?#?#?#?#?#?#?#? 1,3,1,6")]), 1); + assert_eq!(part2(&vec![parse_row("????.#...#... 4,1,1")]), 16); + assert_eq!(part2(&vec![parse_row("????.######..#####. 1,6,5")]), 2500); + assert_eq!(part2(&vec![parse_row("?###???????? 3,2,1")]), 506250); +} + +fn main() { + let input = parse_input(include_str!("input.txt")); + println!("Part 1: {:?}", part1(&input)); + println!("Part 2: {:?}", part2(&input)); +} diff --git a/2023/day12/src/test.txt b/2023/day12/src/test.txt new file mode 100644 index 0000000..eaa8c26 --- /dev/null +++ b/2023/day12/src/test.txt @@ -0,0 +1 @@ +?###???????? 3,2,1 \ No newline at end of file diff --git a/2023/day12/src/test2.txt b/2023/day12/src/test2.txt new file mode 100644 index 0000000..023b5c4 --- /dev/null +++ b/2023/day12/src/test2.txt @@ -0,0 +1 @@ +???.### 1,1,3 \ No newline at end of file