Compare commits

..

17 Commits

Author SHA1 Message Date
f05ef0e7b6 day 23 2022-12-23 22:52:24 +01:00
8f3d66131e last few skeletons 2022-12-23 21:38:09 +01:00
ea1c26772e day 22 2022-12-23 21:30:24 +01:00
19a0956873 day 21 2022-12-22 01:01:43 +01:00
ff2a983332 ignore slow tests 2022-12-20 20:39:46 +01:00
5406dfa6f8 day 20 2022-12-20 20:39:38 +01:00
7c6b17c3e2 some minor pruning, but whatever 2022-12-19 23:43:04 +01:00
dee8ebe78e day 19 2022-12-19 23:28:17 +01:00
8cb4f331f1 day18 2022-12-18 12:08:19 +01:00
8b1c3ff175 day17 2022-12-17 17:57:02 +01:00
628e556063 day 16, but with a lot of pain 2022-12-17 14:59:38 +01:00
075817691c day 15 2022-12-15 12:44:25 +01:00
1e0583e538 day 14: while not wrong, +2 is better than +3 2022-12-14 19:51:39 +01:00
7303f15e2d day 14 2022-12-14 19:50:38 +01:00
05f6b72adc day 13 2022-12-13 23:03:59 +01:00
9675fd15dd clippy happy 2022-12-12 20:11:45 +01:00
088f08075a day 12 2022-12-12 20:11:23 +01:00
54 changed files with 13221 additions and 10 deletions

271
Cargo.lock generated
View File

@@ -6,9 +6,14 @@ version = 3
name = "aoc2022" name = "aoc2022"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"bitvec",
"derive_more",
"itertools", "itertools",
"nom", "nom",
"num", "num",
"petgraph",
"rayon",
"xxcalc",
] ]
[[package]] [[package]]
@@ -17,12 +22,129 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "bitvec"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c"
dependencies = [
"funty",
"radium",
"tap",
"wyz",
]
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "convert_case"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
[[package]]
name = "crossbeam-channel"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521"
dependencies = [
"cfg-if",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-deque"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc"
dependencies = [
"cfg-if",
"crossbeam-epoch",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-epoch"
version = "0.9.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01a9af1f4c2ef74bb8aa1f7e19706bc72d03598c8a570bb5de72243c7a9d9d5a"
dependencies = [
"autocfg",
"cfg-if",
"crossbeam-utils",
"memoffset",
"scopeguard",
]
[[package]]
name = "crossbeam-utils"
version = "0.8.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f"
dependencies = [
"cfg-if",
]
[[package]]
name = "derive_more"
version = "0.99.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321"
dependencies = [
"convert_case",
"proc-macro2",
"quote",
"rustc_version",
"syn",
]
[[package]] [[package]]
name = "either" name = "either"
version = "1.8.0" version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797"
[[package]]
name = "fixedbitset"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"
[[package]]
name = "funty"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c"
[[package]]
name = "hashbrown"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[package]]
name = "hermit-abi"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
dependencies = [
"libc",
]
[[package]]
name = "indexmap"
version = "1.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399"
dependencies = [
"autocfg",
"hashbrown",
]
[[package]] [[package]]
name = "itertools" name = "itertools"
version = "0.10.5" version = "0.10.5"
@@ -32,12 +154,27 @@ dependencies = [
"either", "either",
] ]
[[package]]
name = "libc"
version = "0.2.138"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8"
[[package]] [[package]]
name = "memchr" name = "memchr"
version = "2.5.0" version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
[[package]]
name = "memoffset"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4"
dependencies = [
"autocfg",
]
[[package]] [[package]]
name = "minimal-lexical" name = "minimal-lexical"
version = "0.2.1" version = "0.2.1"
@@ -129,3 +266,137 @@ checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
dependencies = [ dependencies = [
"autocfg", "autocfg",
] ]
[[package]]
name = "num_cpus"
version = "1.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5"
dependencies = [
"hermit-abi",
"libc",
]
[[package]]
name = "petgraph"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6d5014253a1331579ce62aa67443b4a658c5e7dd03d4bc6d302b94474888143"
dependencies = [
"fixedbitset",
"indexmap",
]
[[package]]
name = "proc-macro2"
version = "1.0.49"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b"
dependencies = [
"proc-macro2",
]
[[package]]
name = "radium"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09"
[[package]]
name = "rayon"
version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6db3a213adf02b3bcfd2d3846bb41cb22857d131789e01df434fb7e7bc0759b7"
dependencies = [
"either",
"rayon-core",
]
[[package]]
name = "rayon-core"
version = "1.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cac410af5d00ab6884528b4ab69d1e8e146e8d471201800fa1b4524126de6ad3"
dependencies = [
"crossbeam-channel",
"crossbeam-deque",
"crossbeam-utils",
"num_cpus",
]
[[package]]
name = "rustc_version"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
dependencies = [
"semver",
]
[[package]]
name = "scopeguard"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "semver"
version = "1.0.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a"
[[package]]
name = "smallvec"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c8cbcd6df1e117c2210e13ab5109635ad68a929fcbb8964dc965b76cb5ee013"
[[package]]
name = "syn"
version = "1.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "tap"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
[[package]]
name = "unicode-ident"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc"
[[package]]
name = "wyz"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed"
dependencies = [
"tap",
]
[[package]]
name = "xxcalc"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c2725420f62b8c706cd7f710b45bc30a702de16b092114b84bd0bb6d9cccdbc"
dependencies = [
"smallvec",
]

View File

@@ -6,6 +6,11 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
bitvec = "1.0.1"
derive_more = "0.99.17"
itertools = "0.10.5" itertools = "0.10.5"
nom = "7.1.1" nom = "7.1.1"
num = "0.4.0" num = "0.4.0"
petgraph = "0.6.2"
rayon = "1.6.1"
xxcalc = "0.2.1"

41
inputs/day12.txt Normal file
View File

@@ -0,0 +1,41 @@
abaaacccccccccaaaaaaccccccccccccccccaacccccccccccaacaaaaaaaaaaaaaaaaaccaaaaacccaaaaccccccccccccccccccccccccccccccccccccccccccccccccccccccccaaaaa
abaaacccccccccaaaaaacccccccccccccccaaaaccccccccccaaaaaaaacaaaaaaaaaaaccaaaaaaccaaaacccccccccccccccccccccccccccccccccccccccccccccccccccccccaaaaaa
abaaaccccccccccaaaaacccccccccccccccaaaacccccccccccaaaaacccaaaaaaaaaacccaaaaaacccaaccccccccccccccaaaaacccccccccccccccccccccccccccccccccccccaaaaaa
abccccaaccccccaaaaacccccccccaaaaaccaaaaccccccccccccaaaaacaaaaaaaaacccccaaaaaccccccccccccccccccccaaaaacccccccccccccccccaaaccccaaaccccccccccaaacaa
abcccaaaacccccaaaaacccccccccaaaaacccccccccccccccccaaacaaaaaaaaaacccccccaaaaacccccccccccccccccccaaaaaacccccccccccccccccaaaaccaaaaccccccccccccccaa
abcccaaaaacacccccccccccccccaaaaaaccccccccccccccccccaaccaaaaacaaaaccccccccccccccccccccccccccccccaaaaaaccccccccccccccccccaaaaaaaacccccccccccccccaa
abaaaaaaaaaacccccccccccccccaaaaaaccccccccccccccccccccccaaaacccaaaccccccccccccccccccccccccccccccaaaaaacccccccccccccccciiiiijaaaaccccccccccccccccc
abaaaaaaaaaacccccccccccccccaaaaaacccccccccccccccccccccccccccccaaacccccccccccccccccccccccccccccccaaaccccccccccccccccciiiiiijjjaccccccccaaaccccccc
abccaaaaaaccccccccccccccccccaaaccccccccccccccccccccccccccccccccacccccccccccaacccccccccccccccccccccccccccccccccccccciiiiioijjjjaaccccccaaaaaacccc
abccaaaaaacccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccaaaaaacccccccccccccccccccccccccccccccccccciiinnooojjjjjaaccaaaaaaaacccc
abccaaaaaacccccccccccccccccccccccccccccccccccccaacccccaacccccccccccccccccaaaaaacccccccccccccccccccccccccccaaaccccciiinnnoooojjjjjjkkkaaaaaaacccc
abcaaaaaaaaccccccccccccccccccccccccccccccccccccaaaccaaaaaaccccaaacccccccccaaaacccccccccccccccccccccccccccccaaaaccciiinnnouooojjjjkkkkkaaaaaccccc
abccaccccccccccccccccccaaccccccaccccccccccccaaaaaaaaaaaaaacccaaaacccccccccaaaacccccccccccccccccccccccccccaaaaaacchhinnnttuuooooookkkkkkkaaaccccc
abccccccccccccccccccaacaaaccccaaaaaaaaccccccaaaaaaaacaaaaacccaaaacccccccccaccacccccccccccccccccccccccccccaaaaacchhhhnntttuuuooooppppkkkkcaaacccc
abccccccccaaacccccccaaaaaccccccaaaaaaccccccccaaaaaacaaaaaccccaaaaccccccccccccccccccccccccccccaccccccccccccaaaaahhhhnnntttxuuuooppppppkkkcccccccc
abccccccccaaaacccccccaaaaaaccccaaaaaaccaaacccaaaaaacaaaaaccccccccccccccaaccccccccccccccaaaaaaaacccccccccccaachhhhhnnnntttxxuuuuuuuupppkkkccccccc
abccccccccaaaacccccaaaaaaaacccaaaaaaaacaaacacaaaaaaccccccccccccccccccccaacccccccccccccccaaaaaacccccccccccccchhhhmnnnntttxxxxuuuuuuupppkkcccccccc
abacccccccaaaacccccaaaaacaaccaaaaaaaaaaaaaaaaaaccaacccccccccccccccccaaaaaaaaccccccccccccaaaaaaccccccccccccchhhhmmmntttttxxxxuyyyuvvpppklcccccccc
abacccccccccccccccccacaaaccaaaaaaaaaaaaaaaaaaaccccccccccccccccccccccaaaaaaaacccccccccccaaaaaaaaccccccccccccgghmmmtttttxxxxxxyyyyvvvpplllcccccccc
abaccccccccaacccccccccaaaccaaaaaaaacaaaaaaaaaaccccccccccccccccccccccccaaaaccccccccccccaaaaaaaaaaccccccaccccgggmmmtttxxxxxxxyyyyyvvppplllcccccccc
SbaaaccccccaaacaaaccccccccaaaaaaaaacaaaaaaaaacccccccccccccccccccccccccaaaaacccccccccccaaaaaaaaaaaaacaaaccaagggmmmtttxxxEzzzzyyyvvppplllccccccccc
abaacccccccaaaaaaacccccccaaaaaaacaaccaaaaaaaccccccccccccccaaaccccccccaaaaaacccccccccccacacaaacccaaaaaaacaaagggmmmsssxxxxxyyyyyvvvqqqlllccccccccc
abaccccccccaaaaaaccacccaaaaaaaaacccccccaaaaaaccccccccccccaaaaccccccccaaccaacccccccccccccccaaaccccaaaaaaccaagggmmmssssxxwwyyyyyyvvqqqlllccccccccc
abaccccccaaaaaaaaccaacaaaccaaaaaacccccaaaaaaaccccccccccccaaaaccccccccccaacccccccccccccccccaacccccaaaaaaaaaaggggmmmssssswwyywyyyyvvqqlllccccccccc
abaccccccaaaaaaaaacaaaaacccaaaaaacccccaaacaaaccccccccccccaaaaccccccccaaaaaaccccccccccccaacccccccaaaaaaaaaaaaggggmmmossswwyywwyyvvvqqqllccccccccc
abcccccccaaaaaaaaaacaaaaaacaaccccccccaaacccccccccccccccccccccccccccccaaaaaaccccccccccccaaaaacccaaaaaaaaaaaaaaggggoooosswwywwwwvvvvqqqmlccccccccc
abccccccccccaaacaaaaaaaaaacccccccccccaaacaccccccccccccccccccccccccccccaaaaccccccccccccaaaaaccccaaacaaacccaaacagggfooosswwwwwrvvvvqqqqmmccccccccc
abccccccccccaaacccaaaaaaaacccccccccaacaaaaacccccccccccccccccccccccccccaaaaccccccccccccaaaaaacccccccaaacccaaccccfffooosswwwwrrrrrqqqqqmmccccccccc
abccccccccccaacccccccaaccccccccccccaaaaaaaacccccccccccccaaccccccccccccaccaccccccccccccccaaaacccccccaacccccccccccfffoossrwrrrrrrrqqqqmmmccccccccc
abccaaaccccccccccccccaacccccccccccccaaaaaccccccccccccaacaacccccccaaaaacccccccccccccccccaacccccccccccccccccccccccfffoossrrrrrnnnmqqmmmmmccccccccc
abcaaaaccccccccccccccccccccccccccccccaaaaacccccccccccaaaaacccccccaaaaacccaaaccccccccccccccccccccccccccccccccccccfffooorrrrrnnnnmmmmmmmccccaacccc
abcaaaacccccccccccccccccccccccccccccaaacaaccccacccccccaaaaaaccccaaaaaaccccaaaccacccccccccccccccccccccccccccccccccffoooonnnnnnnnmmmmmmccccaaacccc
abccaaacccccccccccccccccccccaaaaaccccaaccccaaaacccccaaaaaaaaccccaaaaaaccccaaaaaaaccccccccccccccccaccaccccccccccccfffooonnnnnnddddddddcccaaaccccc
abccccccccccccccccccccccccccaaaaaccccccccccaaaaaacccaaaaacaacccaaaaaaaccaaaaaaaacccccccccccccccccaaaaccccccccccccfffeonnnnneddddddddddcaaacccccc
abccccccccccaaaccccccccccccaaaaaacccccccccccaaaacccccacaaacccccaacaacccaaaaaaaaacccccccccccccccccaaaacccccccccccccffeeeeeeeeddddddddcccaaacccccc
abcccccccccaaaaccccacccccccaaaaaaccccccccccaaaaacccccccaaaacccaaacaccccaaaaaaaaaccccccccccccccccaaaaaaccccccccccccceeeeeeeeedacccccccccccccccccc
abaccccccccaaaaccccaaacaaacaaaaaaccccccccccaacaaccccccccaaaacaaaacaaacaaaaaaaaaacccccccccccccaacaaaaaacccccccccccccceeeeeeeaaacccccccccccccccaaa
abaaacccccccaaaccccaaaaaaaccaaaccccccccaaacccccccccccccccaaaaaaaacaaaaaaaaaaaaaaacacaaccaaacaaacccaacccccccccccccccccaacccaaaacccccccccccccccaaa
abaaaccccccccccccccaaaaaaccccccccccccccaaacccccccccccccccaaaaaaaccaaaaaaccaacccaccaaaaccaaaaaaaccccccccaaccccccccccccccccccaaacccccccccccccccaaa
abaaccccccccccccccaaaaaaacccccccccccaaaaaaaaccccccccccccccaaaaaaaaaaaaaacaaaccccccaaaaaccaaaaaaccccccaaaaccccccccccccccccccaaaccccccccccccaaaaaa
abaaaccccccccccccaaaaaaaaaacccccccccaaaaaaaacccccccccccaaaaaaaaaaaaaaaaaaacccccccaaaaaacaaaaaaaaaccccaaaaaacccccccccccccccccccccccccccccccaaaaaa

449
inputs/day13.txt Normal file
View File

@@ -0,0 +1,449 @@
[[[],10,[[6],[]],3,1]]
[[6,8,[9,2],7,2],[[10,[4],[6,2,9,2],[8,8,9]],8,[4],[[0,2]]]]
[[10,[[2,3,9,10],[8,4,3,8]],2,2,[8,8,2,[2,0,9]]],[[[2,0,7,4,2]],9,[[3,8,7,3]],3,9]]
[[1],[[]],[1,[]]]
[[[[10,4,9,5],[9,10,0,2],8,[],1],3,[4],1],[6]]
[[[[10,5,2,0]],10],[[[8,6],8,[3],[4],0]],[2,10,[9,[]],9,2],[1,3,[1,[4,9,9],[7,2,1,0],[5,2,6,1]]],[[[4,9,1,7,2]]]]
[[2],[],[],[3,10,6,0,[0,[7,2,8],4]]]
[[],[0,[0,7],5,[7,[9],9],1],[[[],4,[],[7,1],[4,9]],[],[1,10],0,[]],[]]
[[],[2],[[[10,8,5,6,1],7,3,[5]],[[2,9,7,7],1],[[0,1,0],[0],1,10,[8,10,4]],0],[[],7,[[10,9,5,6,3],3],[[1,1,6,9],6,3]],[6,[[5,4]],[]]]
[[4,3],[[2,8,[8,5]],[3],[1,[10],7,[10,2,5,6]]],[6]]
[[],[[],[3],[0,6,5,10],[]],[],[[]]]
[[2,[],8,[3,2,8,3]]]
[[3,7,10,6,[[6,2,3,10],[],[6],[2,10,9]]],[[[4,8,9],[10,0,1],0,0,[7,1,10,2,5]],4,9,9],[10],[[]]]
[[[8,9,[3,8,3,2],2,7],4,[[4,3,2,0],1,[8,6],[]]],[]]
[[],[[[],6,5],[[8,5],1,[6,2],8,6]],[[2,[],7,6,[7]],[6,10,[],10,[9,4,9,6]],[1,1,4,[5,8],0],7],[0,10,1],[7,[[3,3,9],8,[],[2]]]]
[[3,9],[],[6,10,[[4,3,2,8],2],[1,[],[5,9,10],9,[7,6]],[2,[4,10],5]],[5]]
[[10,6]]
[[[[],[],3,[0,6],9]]]
[[7,4],[[[]],8,[[],3,7,[0,10],[8,7]]],[[8,10,8],6,[],4,[7,8,[2]]],[[[10,9],2,7,[],4]],[]]
[[[[7],4,5,5,[2,0,8]],0,[[10,5,8],[5,8,3,7],[5,10,6,3],2],7]]
[[[],[[10,1,3,0,2],[]],2,[[2]]]]
[[4,6,7,5],[[[10,10,8],10,[],10],1,10,[[],4,[],[7,6,8,4]],7],[5,9],[5,[[9,6],[10],2,[2,7,6,6,9]],2,8,[[8],7,2,8]],[]]
[[8,[[10],[9],[8,10,10],[6,0,6,10,1]]],[[10,[10],[8,3,6,7,2]],[],[],0,10]]
[[],[3,8],[[[2,4,1,10,0],0,2,[10,8]]],[[[8,10],10],[]]]
[[[1,[7,3,10],8,10,[10]],[6,1]],[0],[[[9],2,[]],10,[],6,[[],2]]]
[[[10,9,7]],[7,4,[[5,5,10,6,10]],[[10,3],4,[7]],8],[[2,[1,4,5]],2,[[],0,1]],[],[0,[[10,2,6,1,4],[6,4],6,3,6],[[8],2]]]
[[],[[[8,8,6,6,10],[9,4,3,7],[5,2],[2,0,7,8]],[5,0,[5,4],3,2],2,9,[]],[6]]
[[[4,9,1],[4,0,[1]],[[4,1,6,6],[6,8,10,5],8,10,3],[]],[3,4,7],[5,3,[6,[0,1,8,1],8,[6,10]],[],5],[],[1,[[3,7]],4,[[3]]]]
[[],[10],[[7,[7],1],[[6,8],3]],[3,6,1,4,[1,[],10,3,0]],[[[9,2],[],[8,5,3],9],4,10,10,6]]
[]
[[[[],[10,2,0]],[3]],[[1,10,4,6],1,[]],[2,[8,[3,4,0,9],5],[4,2],[4,5,[8]],4],[[[0],0,9],9,3],[8,10,[[5,8,2,9],[6,9,3,5,2],[9,4]],9]]
[[9,6,4,8,5],[[3,[7],8,1],5],[9,[[3,0,4,1,8],[2,5],[7,0,1],9]],[10,[[7,3,5,7,6]]]]
[[8],[2,[],[4,4],7]]
[[[[6,0,4,3],0,[],[2],5],[[8],[4,8]]],[8,[[2,9,10,9,2],0],[],[[2,6],4,[8,0,0,1]]],[[4,1,10,1,3],[[5,2,7,10],[0,3,2,0,8],[2],[4,8,6,2],2],[10,5,6,[],[10,6,1,3,4]],9],[2],[[[2,2,2,6,9],8],[[],[0]]]]
[[5]]
[[[[8],10,[4,8],[7,3,6]],6,3,8],[9,[]],[[[]],[],[[7,5,10,1]]],[0,[[0],[],4],[],[[6,10,5,1,10],[2,7],[2,5,3],7,[]]],[6,[3,2,[],[6,7]],[[]]]]
[[],[9,9,[[5,7,9],[8,9,10],8,[3,8,2],[9,7,10,8]],1],[],[],[9,[[2,5,2,1,6]]]]
[[0,4,[9]]]
[[],[],[7,9,0,[],[2,3]],[10,4],[[],[4],[0,[1,0,7,4,8]]]]
[[[[0,8,3,7,3],[2]],[[1,5]],5,8]]
[[9,[[]],[2,[5,10]]],[[],6,[3],[[0,5],8,4,1,[2,10,10]]],[3,1],[1,2,[],[5,[0,10],[4,10,3,2,8]],10]]
[[0,10,[[6,1,4,10],2,3,[6,1,1],[]],[[10,5,3]],3],[],[]]
[[0,7,[1,[],4,2]],[5],[9],[[[6,1,0,6,10],[10,3,7,8,5],2]]]
[[],[[],2]]
[[[5,10,6,4,4],0,[6,10,[7]],[[3,9,3,10,5]]],[0],[[[3,7,2,2],[7,4,10,4,8]],[10,10,5,7,3],[[2,10],[5,3,0,2,0],[6,3,6],[9,0,4,6,6],5],3,[]],[[[5]],4,[1,9]]]
[[],[[2,[1,1,5,4,9],[7],[3,9,3],6],[10,2,[],3]],[[],[],5]]
[[[3,[1,1,1,0],[8,3,3]],[8,[0,5]],8]]
[[[7,5,8,[9,0,10,10,0],[1,4,0,1]],2,3],[[5],[]],[4,[5,[]],[9,1,[5,6],[9,0,2,3,7],6],2,[[4,9,9,2,5],7]],[0,[5,8],[],0,[0,5]],[[[5],10],7,[8]]]
[[[]],[[[5,10,3],7,7,9,[8,9,3,7,2]],4]]
[[4,8,[5,[7,7,3,8]],[10,1,[8,7]],6],[[6,7,[1]],[[]],10],[[],6,[]],[[[10,1,10],[7,5,0,6,3],[5]],1,[[0,6,4,3],[10]],[3,3,6,[2,7,1,9]]]]
[[5,7,[]],[4,[[1,4,1,5,8]]]]
[[6,6],[3,4,8,8,[5,[6],10,9]],[[],4,[5,4,[7,6,9,10],9],9,[[4,3,1,6,2],[10,3],[]]],[[[7,1],8,[10,8],[9]],[[1],[1],[0,8,6,4]],[9,[8],8,1],[],[[4,2],[8,4,3,6],[0],10,[3,8,6]]],[7,[3,5],[1,[0],6],[7,8,[],1],[[9,10,6,4],[10,1],3,7,3]]]
[[],[3,[8],[6],[]]]
[[5,8,[9,[8,10,5,8],6,[3,6,1]],[2,2]],[],[9,[],[[],[8,4],[8,4,5,7,6],7,7]],[],[1,[10,6,[10],[1,7,5,10],[3]]]]
[[2],[[5],4,[[],[0,6],4]]]
[[[],10,[9],[[8]],[4,[0,6,10,6,6],1,3]],[[],[2,[5,9]],[[9]],8,[1,4,5,[],[]]],[[5,[2],7,[],9],[]],[],[10,[1,[],4,2,[]],[7,[],7,[6,6]],1]]
[[],[0,[[6,7,7,8],7],[[7,9],0,3,10]],[],[],[10,[0],[]]]
[[[1]],[],[[[0,1,6,3,9],[],3,6,[]],[7,7,0,[10,10,2]],[7,8,[6,3],10],[]],[[[],[],5,7,[2,0,2,2]]]]
[[[[5,3,8,8]],8],[10,5,[]],[6,[],3,[[5,8,8],[1,10],[0]],5],[[[9,8,3]],[5,[9,7,9],4,[10,9,0,0,3]],5,[3],7],[[7,0,0],4]]
[[],[[6,0],10],[],[],[[3,5,7,[0,10,7,9,10],6],[[1,3,3,10],[1,2],[]],1,6,9]]
[[5,2],[3,8],[9,[1,[10],[10,7]],10,[4,[],10,1,3]],[[[6,9,6,10,7],0,[],[6,1,2]],[[9],8,3]],[[5,[8,10,4,9],3,[9,8,9,5],6],[7,10],[4],1]]
[[10],[3]]
[[7],[[],[[8,4,4],1],8,9],[],[0],[[3],[[2,7,0,5,6],[8,3,7],[9]],[[1,0,2,3]],7,3]]
[[4,[6],[[2],9,8],[1,[5,9,1,10,10],9,[7,4,1],2],[8,[1],[10,7],0]],[[[],10]],[],[6,7,[10,10]],[10,5,4,5]]
[[],[[6,9,[8,0],[10,8,0,8,4]],1]]
[[[6],[[],[],[1,9],[]],8],[[6],6,5,[[8,7,1]]],[[4,[4,5],[3],[10,8,9,8,6]],1,8,[1],[9,9,[10,3,3],[8,0,7,2]]],[8,[7,9,[6,2,5,2,9],5],8,[[]],3],[5,[10,[1,0,3,2],8,[0]],2]]
[[[3,[0,7,4,6,7],[],8,[8,5,6,10]],[],2,[7],[[]]],[],[[[3,9,2,2],[8,1,1,7,4],[10,1,0]],[8],5,8],[5,3],[5,2,[[],[3,2,1,4]]]]
[[[1,[9,9,4],8,7,[3,3,9,2]],1,2]]
[[[[10,0,0],[0,4,0,1],8,[3,4,1],[7,4,0,7]],[7,[3,5,6,3,10],7,[],9]],[],[2,[[9,8,1,0,4],1],[1]]]
[[[],4,0],[],[[9,4,[9,3,6,1,5]],[3],[]]]
[[7,[[9,3],2,[9,10,6]]],[7,0,10],[[5,[]],7],[5],[10,[2,2,[],5,4],5]]
[[[9,3,10,4]],[],[],[[[5,4],[9,5]],[9,[]],8,10,5]]
[[[7],3],[[[3,5,10,8,4],3,0,8],0,0],[9,[[6],[9,7,1],[9,6,2],[9,0]]],[]]
[[0,[[5,9,4],7],9,[2,[3,1],9]],[],[[[6],2,[2],[6,5]],4,8,6],[[],[]],[4,[[],10,8,4]]]
[[[3,[10,9,5,6],7]],[[1,7,[1,5,7,9]],[4,4]]]
[[],[[],[1,[10]],[4,6,[8,8],[5,4,0,9]],0,[8,3]],[[[8,5,5,7,6],2,[4,10,5,9]],[[6,5,10,9,9],9,6],[]]]
[[[[5,10,0,7]],5,3]]
[[[[5,7,2],5,7],[[9,7,3]]],[[1,[8,3,3,4,10],[0,10,4]],1,0],[7,1,[[8,4,5],[5,4],5,[10,3,10,9],[3]],1,[7]]]
[[[7,6,[],3,[0]],[[10],0,[],2],[],[5,3,4,[9]],[[],3]],[[[2,6,10],4],[[],[4,1,2],[10,3,6,8,9]],7,7],[]]
[[1,0,[[7,7,6,2],10],[],[2,[],1,4]]]
[[2,[8,[8,7,5],0,4],[7,2]],[[[10,2,2,0,8]],10,[[6],[7,9,3,0,10],9,[9,3]],[4,[2,5],[4,1,0,7],5]],[]]
[[],[7,4,[[6,5],[5,5,7,6,3],[0,2,7,6,3],4]],[[[6,4,2,4,4],10,3]]]
[[[1,2,6,[9,1,8,10],1],[],3,[],1],[9],[[[9],[],6],0,[]],[],[]]
[[7,10],[5,[]],[[[7],5],[[3,9,9,5],[],8,[0,1]],[],[[0,5,6,4]]],[3,0,[9,[9,6,6],[0,5,3,5]],[[],4,2]],[10,1]]
[[[[0],[5,5,0,3,6],10,4,7]],[0]]
[[[[6,6,7,10,8],[4,8,3,5],[1,4]],[[9],7,10,8,[4]],6,[],[0]],[10,[]],[4,[4,[],[]],0,[9,[0,7],[9,4,2,5,2],[9]]],[[[9,7,4,6,0]],[1,2,[3],[8,4,1,10,0],2],2,[10,0],1]]
[[[[6]],[[9,0,2,4,5]],3,[[6,5,3],9,2,[10,7,0],0]],[0],[3],[]]
[[],[1,[]],[],[[],[[]],8,9,3],[10,[1,[],[5,6,10],[6,4]],[9]]]
[[5],[2,2,[[5,6,3,10],[4,2,8,9,5],[10,6,9],[2,8],6],1,[[],[7,3,5,3],0]],[[[7,3],[4,0,5,8,2],5,2,[6,1,5,10,4]],[],1,4],[2]]
[[8,[[0,6,8,4,0]],0,[0,3,[8,3,9,4,0],2],7],[1,7,4,5],[[[7,6,9,1,2],10],[[9],2,9,[7,1],10],7,[6,8]]]
[[1,4,9,9],[[[10],[],4,3,3],2,8],[9,[],8],[[9,7,[1,5],[10,8,1,0]],[]]]
[[5,2,2,[9,10,5,10,[2,6,10,10]],[2,2,0,[],8]],[[8,[4],6,9,[2]],6,[2],3],[10,[[8,0,0,5,9],[5,1,1,0,7],[9,10,0],6,[5]],3,2],[4,[8,[1],[4,0,3]],4,7,[[9,6,6,7],0]]]
[[[[]],6,1,[[6,9,2,10],[]]],[6,[[4,6],9,[4],[0],[2,2,6,7,8]],[2,1]],[[[10,9,2],5,[6],5,10],[7,6,6,[],5],9,[]]]
[[[1,6,[5,0,2,3],[2]],[]],[10,0,[[0,0,1]],[[6,1,8,6],6,[10,9]]],[4],[5,0]]
[[],[[[2,2],[9],0,5],[[8,3,9],8,[],0]],[8,9,[[4,0,7],6,[],8],[3,[],0,[4,4]],4],[[9],1,[]]]
[[[[7,0,4,3,4],[],0,[10,6,5]]],[[[9,4,8,7,9],[8,10],5,[7,0,4],[9,5,0,7,6]]],[],[[9,6,[8,0,7,2],[]],3,1],[[[3,0,10,1,0],[5,2,1,5,2]],[[7,3,2],[7,5,10,2],5,3]]]
[[[[],[],[],4,10],[5,[],[7,2],[10,5,2]]]]
[[7,[[7,6,3],7],[9,3,[2]]],[[[3,5],[9,5],8],10,3,10,[1,2,5]],[4]]
[[[8,[],0,[2,4,9,0,10],[7,5,2,10]],[[],[],8,10,[5]],1],[],[5,[4,[],[4,10,10,7,6],7,1],[[3,9,2]]]]
[[[[4,4,8,10,4],10,[9,9,6,2,10]],[7]],[10,[[0,2,2,1],[9,6,0]]],[[[0],[0,5]],1]]
[[7,1],[],[[],[],[[5,0],[6,3,1,6],2],[[0,4,10,9]],[[],0]],[[[2],[4,7,3,0,5]],[[3,9,3,1],[1,8,10,7],[],3,[4,0,10,1,10]],[6,[4]],8,3],[6,[],[],10]]
[[[]],[1,10],[[[6,7,8,10],[6,0,4],[4,9],0,[3,0,1,7]]],[1,0,[9,[8,2,9]]]]
[[1,2],[6,5,[0,6,[],1],4]]
[[],[[[10,3,8,1],[1,9,10,3,7],[9,7,1,7]],9,4,9,1]]
[[],[[4,[10,10,7,9],[1]]],[[3,[],[10,5,3,1]],6],[[[],4,9,9],2,[2,[3],9]]]
[[],[],[[[3,10,4,7,0]],3,[7]],[[3,10,[6,5,2]],2,4],[3,[],[[10,3,8,7]]]]
[[],[[[3,10,9,8,10],5,[5,4,10],5],3,7]]
[[[4],8,[9,[10,2,1],5],[5]],[5,9],[7,6,4],[]]
[[8,9,2]]
[[[0,3],9,2,10,[[9,0,3,4],0,7,[2,4,5],[8]]],[[[],[10,0,1],[4,4,7]],7,10],[],[[[0,3,5,3,10],0,[7,2,7]],[[8,9,7,9],7,[]],[1,[3,6,4,2,5],[3],[6],[8,0,3,1]]],[[7,6,[5,6],8,[5,10,5]],[[],7,10,10]]]
[[7],[[1,10],[2,5],6,[[3]],9],[]]
[[6],[[],6,4,[],[7,2,[8],[]]],[[6,3],8,8]]
[[],[],[4,[[7,1,5,5,8],[0,10,3,6],[10,9,0]],[10]],[[[],[3,5,0,8],[9,1,6,9,4],[9,4]],8,2],[6,[7,3],2,[],0]]
[[[[2,0,4,6,9],[10,1,3,7,10]],0,[],10],[]]
[[[[3,0],7,[10,2]]],[],[0,[],6,[],[[8,3,7],8,[2],5]],[[0,3,[]],7,8,3,[6]]]
[[[3],9,[[6],[],8,10,[]],1],[[]],[1,[8,0,[7,7,1,8],8],3],[0,[],[],[[],0,[2]]],[[9,[10,6],5],[[],7],[[9]]]]
[[2,[8,3],[4,8,[6]]],[[[],3],[0,[9,6,2],5,10,0]],[[]]]
[[[7,6,3],[[5,3,2,3,10],[10,10,1],[4,1],[7,8,1,1,4]]]]
[[[]],[[0,[7,8,6,6,7],6,[1,10]]]]
[[7,5,7],[8],[10,[0,5,7],3]]
[[[[0,4],[3,1,0,0],[10,8,10]],[[]],[0,[7,8,2],[5,9,6]],7,[[1,8],[3,4,2],[10,8,7],7]]]
[[[1],7,0]]
[[5,4,[[],5],[5,1,[7,8,1,7,9],[0,4,5,3],3],[[9,8],[1,3,0,0],6]],[8],[],[[0,[0,5,10],[3,8,8]],7,2,[10,[],7]],[6,[],[3,10,[0,2,0],[2,2,4],[0,7,0]]]]
[[[],8,7],[3,7],[]]
[[[1,8,[4,6],7,9],[[4,0,10,6,3]],[[1,10,9,0,3],[1,3,0,0]],[1,0,8],4],[[[0],[8,6,6,2],3,4],[8,[2],9],[[2,10],[4,0,4],[8,1,2]]],[[[3,6,5,4,2],10,0,[9,9,0,1,8],[3,7,4]],9,[[6,9],[7,4,8,4],3],0],[0,[[3,6,7,9,7],[0],[],[2,7,10,1]],[[6,7,4,6,4],5,[6,10,0],[0,9,8,3,4]]],[[5,10]]]
[[[[1,3,5],0,[4,2,9]],[0],9,[[],[3,10],[],[3],[7,4]]]]
[[0,[2,[8,5],9],4],[[],2,[6]],[4],[]]
[[1,[10,4,[],[2,6,3,10,6]],7,[[8,2,2]]],[[10,[],[8,4,6,10]],2],[1,[8,3,7,[2,0,1,3,10],5],[]]]
[[[[2,8,4,8],9],5,[[],1,3,[2]],[8,4,[],5,[0]],0],[10,[],2,[1]],[[[10],1,[],[6,4,6,10]],[5,8,[4,4,5,7,8],[],[5,3,4]],5]]
[[8,5,0,[[2,8,6],0,[7,5],[8],[5,3,7]]],[],[],[[1,[4,0,10,5],[3,1,6,7]],3,[]],[[[9]],10,5]]
[[5,[[9],6],[1,[10,6,0],[],9,[4,4,8,8]],6,5],[[],10,1],[[],[0,2,8,3,5],0,[[],5,[6,8,7,3,0],[5,3,9,9,6]],7]]
[[],[8,2,[2,[9,5]],[3,[],5,10]]]
[[[[1,10,6],2,8,[1,9],3]],[[4,0,7,[2,6,4,10,8],[5,2,6,4,2]],4,[4,9],[2,[9,4],[],6],9],[],[]]
[[[6],5],[],[0,[7],[[10,0]]]]
[[[3],6,7,[[],[9,3,8],[10,1,0,0,8],[7],[]]],[]]
[[0,4,10,[3,[7,6,5,0],[],4,[4,1,1]]],[[[4,8,6],[2],10,[9,3,4,8,5],6],[[7,5],6,3],3]]
[[[[]],[[],5,[8],[6,8,4,6,3],[4,2,8,1]],[0,[3,4,9,5,3],1],[],7],[1,[9],[[0,1,5,5,9],[6,3,9,3],[7,4,10],9,3],7,5],[8,[[10,1,4],1,0],1,1,0],[]]
[[[[7,7,6,6],1,[2,5,0,1]],[10,[0,5,7],[9,1,1,10,0]],10,1]]
[[[0,7],[2],[[4,10,0,3],[3],[6,0,6],3]],[[9,6],4,5,[1,7,[10,2,8,10],[],2],6],[[],[3,1],[8,10,[3,2],3,1],8,9],[],[4,[[],[7,3,7,7,3],2,3,[7,9,6]]]]
[[5,3],[[[],9,[7,2,0,6,4],7,2],[8],[[2,1,3,8],[],[4,0,8],1,[]],1],[],[3,7,[],[[],[1,10],9]],[[9,8],[6],[7,1,9,[],[]]]]
[[2,7]]
[[[6,1,9,[]],[[7],[],3],[1],4],[[3,0,6],1,6,[[5,5],1,[9,4,3],[],[3]],[6,[8,10,9,9],6]],[[[9,5,6,9,2]],[7,[10,7],[9,10],1,[1,7,7]],[8,[4,2,5],[0],[7,0,3],[0]],6,[[0],[4,1],[1],[7],5]]]
[[],[],[7,[2,8,8,[]],3,7],[[4,8],[],[7,[10,6,9,5,6],2],[[3,5,9,10,6],0,[0,0],[9],[2,7,6,9,5]],[0,6]],[[6,3,[0],10],[],10,[[6,8],3,[2,3,2,1],[],[10,1]],[]]]
[[[[5,8,2],5],[[10,9,9,4],[2],[],8,6],2],[[[4,4,8,4],[1,0,1,7,2],[3,7,3]]],[7],[0,1,[[10],[6],9,[4],5],4,[[5,10],[8,1,7,5,9],7,6]]]
[6,10,0,0,5]
[6,10,0,0]
[[1,[]],[5,6,5]]
[[2,10]]
[[[1],[6,[2,4,5,2],[1],[7],[10,10,0]],[3,0,[3,1,3,0],[7,10,0,7,8],[9,1,7]],[5,[8,4,6,3,6],0,[4,4,5,10],10],[[6,8,3,2,5],7,3,[10,10,3,7,3],1]],[[[8,1],[4,9,3,0,0],4,10],[],2]]
[[],[],[5]]
[[6,[7,[3,6,9,0,6],[6],[6,5,8,9,0]],5,9],[8,5,7,5],[10,4,0,5,[[]]],[]]
[[[8,2,8],6,[[1,6,1,6]]],[[8,7,[1,3,10],[6,5,5],[4,9,0,9]],[1,6,0,5]],[[5],2,8],[[5,4],[3,[7,2,8,10],9],[[3,7,8,2,1],3,2],[[3,3],5],3],[[[7,7],[9]],[[9,3,9,2,1]]]]
[[8,[[7],[6,2,4,1,8],8,[0,1,0,7,5]],[[8,5],[4,9,2,6],[2]]],[],[0,[[8],[4,6,2,10],[4,10,8]],[[3,2,1]]],[2,10]]
[[[[],[5,10,1,9]],[[5,1,10,7],[10,9]],[9,[],7,[]],0],[3,0,[[10,9,7,3],[],[0,3],10,1],10,[[2,4,10,4],[4]]],[[]]]
[[[[7],[6,4],[5],[1,0]],[[2,3,1,3],[],5,6]]]
[[[6,[],[8]],[0,[5,4,2,5],9,6],[[2,8,4,2],9]],[1,[1,[0,5,5,4,10],[9,4,7],8]]]
[[[[8,2],2],9,5],[3,0,[],2,[2,7]],[],[[],0,[[]],[[4,0,9,2],9,[8,5],7,2]]]
[[[[1],5],[[6,7],2,2,1,[3,8]],[1,10]],[]]
[[4,[]],[6,[3,[4,4,7,6]]],[10,8,1],[[[3,1,1,0,7],[1,9,10,6,2],[10,6]],[2,[9,9],0,9,[]],[4,8,3,[]],[[5,4,8],2]]]
[[[0],[8,9,0],5]]
[[[0,8,[0,8,10,6,7]],[6],1,7,[8,6]],[0,[],[[6,6,3],[5],[2,8,10,6],[]],2,[[7,8,7],7,6,[],[0,4,1]]],[5,10],[]]
[[2,[[9,8,4],9,4],[1,8],0]]
[[1,5],[1,0,[4,3],2],[[[7],[6,5,2,2],8,[7,9]]]]
[[],[1,[0,10],[[8],0,3,3],[[3],2,[],[8,4,6]]],[[[0],9,5]],[1],[7,1,[8,3,[1,2,7],[1,8]],2,[1,0]]]
[[],[]]
[[[[8,7,4,2,9]]],[7,5],[1,[[2],6,[7,4,10],[9]],[9,8,[1,8,6,8,7],1,1]],[[[10,4,4]],[[5,8,10],[1,7,4],1,7],10,2,[2,[5,0,8,1]]]]
[[9]]
[[7]]
[[],[1,[[7,3,9,8,10],[7,8,4,2,7],9,[2,7,8],[10,7,2,9]],3,9]]
[[[],[5,10,4],5],[[10,[8,10,2,10],[8,8,10,0],5,9],[[10,7,5,10,5],[10],7,[10,3,10,4],[5,0,0,4,7]]],[],[0,[[5],6,2,10,9],[[2],[1],[10,1,5,1],[8],5],[3,9,1]]]
[[2,[2,[8],[7,1,9,1,8],4]],[[5,[2,8,3],9],4,3,[[3,2,0,10],3],3],[[8,4,2,[5],6],8,[],[[10,7,7,7],6,[7,4],[9,3,2,6],[10,4,10,5,8]],[9,1,6,5,[]]],[[[10,9,8,2],3],[1,10,[0,2,8],6]]]
[[[[4,7,8],7,[],9,[0,6]],[],8]]
[[[2],[[]],[[],[4,0,10,5],5,3,8],[8]],[[4,1],[2,[],4],[[1,9,10],0,[3]]]]
[[[4,[7,6]],[5,1,[],[2,6,10]],[10,0,[],[9,3,10,8,5],[9,0]]],[10,9,3,[[9,8,2],4]],[[[6],10,9,3,2],[[10,9,2,10],7,4]],[[2,3,[9]],[[0],0,[5,8]],2,[]]]
[[[[2,6,10],[4,8,1,10,6],1,[4,0,10,4,5]],[[5,8,10,1,0],[10,4,2,4],[5,8,0],5,1],[10,7,10],[[2,7,5,1],[9,0,5],[8,5,4,9]],[6,[2,8],[7]]],[[3,8],[[3,9,6],[5,4,2]],[]]]
[[[],[],7],[]]
[[2,9,10,6]]
[[],[],[[7,1,8,[8],6],[9,[2,10,7,10],[],7,[6,8,4]]],[[7,6,8],[3,[3,0,4],[8,7,2],[4,0,0]],10,7],[]]
[[],[4,[]],[[[0,2,4],9],[[0,10],9,9],6],[1],[7,2,2,9]]
[[[],[[3,5]],2,[[7,1,5,7,8]]],[[0,[],[2,4,9],2],[7,4],[],3]]
[[3,[],9,5,[7,[4,4],[4,5,4,4],9]],[[1],[]]]
[[[4,9,[5,2,1,8,3],[],[8,5,7,5]]],[[[5]],[[]],4,4],[0,[1,[4,7,9]],7,[[0,3,8,5]]]]
[[],[9,9,[3,10,8,[],[5,9]]]]
[[[[6,7,1,8]]],[[[2,8],[2,9,5,1,4]],[[7],[1,10,3,4,2],9]],[[[8]],7]]
[[1,[9,[],[10,4,4,4]]],[[2,[8,3,4]]],[[[5,5,1,3,10],8,8,10,7],[9,[2,10],[3,3,3,5,3]],[[4,0,8],10]],[9,[[9,8,3,7,8],9,[9,6,9,8],[6,7,6],[]],[]],[4,[[7,4,1,4]],[0]]]
[[[[2,10,2,8,0],8,8,0,4]],[[],[[1,7]],[9,[8,6,0,2,9],[],2]],[],[[7,0],7]]
[[9,9,7,10,[[6]]],[2,[[6,9,3,9],2,[7,3,2,2,3]],4,7,9],[[4,7],9,[2,[1,1,8,5,1]]]]
[[[6,7,9,[]],[]],[],[5,6,5],[]]
[[[[5,5,1],0,8,6,4]],[],[[[]]],[0,6]]
[[[6,[],[2,2,10,0,8]],6,[1,2],[9,9,0,[2,8],[6,9,9,3]]],[8]]
[2,7,5,7]
[2,7,5,7,7]
[[10,[[6,4],[],[1,4,0]],[]],[7,3,[1,6],5,[10,10,[],[5,5]]]]
[[[[1],10,[7,10],[]],1,0,[[2,10,7,6],[1,9],3,9],5],[7,[[9,2,0,4,1],2,0,2,9]],[[7,[6,10,9,6,3],[],2,1]],[6,6,[8],4,4]]
[[],[[7,1,[7,7,9,1],5,[5,2,3,10]],2,5,2,[[7,7],3,[]]],[],[[[10,5,3,9,5],2,2,5]],[[9,[7,6,3,7]],[[6],[9,1,10],[4,5],[10,4]],[2,[]],[]]]
[[],[[7,1],[6,[]]]]
[[0]]
[[10,[],[[5,4,1]]],[],[0,[[3,0,8,9],8,[],[9,4],9],[5,[6],10,[2,8,8,2,10],[0,0,4,7]],6]]
[[10,[4,3,[4],[9,2,1],[4,9,1,10]],3],[10,[7,[3,0,2,3],8,1],[8,7,[]],4],[4,2,5]]
[[3,10,7,[[]],[[6],6,9,[10,4,9],6]],[[[6],[3]],[[8,2,6,5,4],[1,8,4],9]],[7,9,[3,10,[8,9,8],[10,8,1,4],6],[[3,6,3]]]]
[[],[[[2,5]],5,1,[5,4,[9,8,4,6],4]],[]]
[[[[6,10,5],[8,1,4,10],[2,5,9,9,4],[],[3]],4,[[1,1,1],[4,8,5,1,0]],3],[1]]
[[7,9],[3,[8],6,7],[[7],6,[[8,4,10,2],[]],2]]
[[[6,2],[],[],[],[1,[1,7,6,6,0],[3,9]]],[]]
[[],[[[3,0,0],9,[6,3]],6,5,[7,3],6],[]]
[[[9],[[],[6,3,1,1,3],[]],[[2,10,9,4],[1,4,9],5,[4]]],[7,6,[],8]]
[[10,[3,10]],[5,[[2,5,5,1],[3],[6],[9,1],2],[2,[1,10,9],9,[9,5,2],2],5,[5,[10,2,4],[6],[10]]],[[9,[],[4],[8,6]],4,[3,4,[1,5,8,9],1,[7,2,8,3]],3]]
[[9,4,6,6],[8,8,9],[]]
[[6,[4,[6,10,1]]],[9],[5,[[2,9,4,3,0],[],[4,9,3],[8,8,6],[]],3]]
[[6,6,[7,6,10,1,3],[[7,10,1]]],[[[9,1,5,0,5]],6,[[],[],[5,2],8,[10,1,1,8]],[5,[],3],1]]
[[[[4,6,1],10,[],4]],[[0,9,[0,2,7],4],[10,[],[6,4,0]]]]
[[6,4,[[0],[9,1,9],[8,8,4],[5,2]],6,7],[[[4],[2,0,6,0,2]],[[],[10,9]],[]]]
[[],[[],3],[[4],10,[[8,5,1],[],4],[[2,9,10,0],2,[9,2],10]],[[3],[[2,2,9],3,[7],[2],3],[[],[7,9,4],[1,6,2,2,6],[7],[]]],[]]
[[6,[9,[]],3]]
[[[[9,3,6,4],0],3,1],[],[0,[[3,1],[5,6,2],[2,10],5,9],6],[[2,[2,8,10,2,8],3],2],[7,0,3]]
[[[],[[10,1],2],5,5,7],[[[3],0,3,5,2],[[8,5,8,3],1],5],[4,[]]]
[[],[[0,5,1,[8,3,4,0,4]],[[9,9,3,3,0],[7,7,3,6,0],[1,2,4,3],[7,8,8]],[4,[9,2,5],5],4]]
[[[[7]],1,[8,1,[],1,[2,4]]]]
[[[],3,4,2,4],[],[[[6,1,10,4],6,[3,9,8,9,5],[8,5]],2,[[6,9,9,1],9,1,9],10],[4,[6,[4,7,10,5]],[0,9],4,[]]]
[[9,5,[[],[1,3],[7],4],[[],[0,2],8],10]]
[[10,[[],[9,8],[5,10,2,3,8],[],[0]],8,8,[6,10,[5],4,1]],[4],[0,[]],[1],[[2],[10,0,1]]]
[[0,[6,7,5],7,10,[[2,8,1,4,3]]],[[[6,0,4],2,[1,0,5,5,8]],7],[[[2,4,7]]],[]]
[[6,[],[5,7],[[10,5,8,2,1],[5,10,2],10]],[[],[[6,4,4],[1,1,7,9,1],[9,9],[]],[],[0,2,4]],[[10,9],[2]]]
[[1,[[9,3,1,2,7]],1,[],[[8],7,[6,4,6,2,7]]],[8,1,[6,[4,2,10,4],9]]]
[[4,[10,10,[9,5],[0,8,1,8],[]],9]]
[[[9,[0,4,5,2],1,6]],[0,10,[7,[],4,9,4]],[[5,9],8,5,4,1]]
[[1,4],[[],[[],[7,1],2],8,5],[[[7,10,9,8],[],6,[10],1]],[[7,7,[]],[]]]
[[10,7,[[9,9,3,2,7],[]],7,[]],[8,8],[[[9,0]],0,7,[]],[[9,9],[[9,1,8,7],[7]],[[4,5,0]]]]
[[],[7],[1,1,6],[],[8,0,[],[[9,9],7,[],[10,9,2,8,6],3],[1,3,[5,3]]]]
[[[],[6,[],10,7,0],3,9,[[2,3,6,1]]],[[[],7,0],8,[8],[[],6,2,2,3]]]
[[],[4,10]]
[[[[8,0,3,9]],5,[9,8,0],[[2,8],[9]],[]]]
[[],[[2,4,0,2]]]
[[[[6,2,8],[6,8]]],[1,9,10,8]]
[[],[5,3,[[]],4],[0,10,[[10,4,4,3,8]]]]
[[[6,[3,9,3],[8,0,8]],1,[[1,8,4],[4]],9,7],[[],[[10,6,9,7,0],[10,6,2],[4,2,3],6,[0,6,9]],[],3,8],[[1,0,[7,6,7,2,6],9],[],1,8],[[[3,7,7,10,3]]]]
[[[4,[9],0,[10],5],[[6],[7],10],[[3,6,6,6,0],6,[7],2],8],[6,5,[8,2,3],[2,3,10,[4,3,3,0,10]]],[]]
[[[]],[6,[[],10],[[3,0,8,2,2],[],[6,6,1],0,[9,10,5,9]]]]
[[[9],[1,[2],1],1],[[[2,4,8,6,3],[2,6],[9,0,4],4],2],[10]]
[[0],[],[[[1,3,0,2],[]],[[5,4,7,5],10,6,10]]]
[[[3],10,3,[8,[7]],[10]],[[1,10],[[],[1,4,2],2,[6,8,0,1,4],[3,4,8,1]],[2,[7],4,2,10],[7,[],[3,6,6,9,3],[7,3]]],[5,[],[],10,6]]
[[0,1,[8,2,3],4,[]],[[4,[7]]],[[10,2,[6,8,8,5],9,[]],[[],[],[7,0,0]],4,7,[9,[8,9,5,9,0],8,[4]]],[10,[[9,6,7,9,2]],[[2,8,3],6,9,10,[]]]]
[[[9,7,0,[8,7]],2,5,10],[2,[6,10,9,1],[7,10],8],[8,6,7,[[0,5,4,4],[2,4],5,1,3]],[],[]]
[[6,7,1],[[]],[7,[2,4,[]]],[[[],6,[3,6,0,3,9],5,[8,8]],[[7,4,6,5],[4]],10,0,4]]
[[],[[[1,3,4],4,[0,2,4,1],1,1],3,[[],10,7,7,7]],[]]
[[8,[1,[1,7]]],[[[5,7],7,[2,6,9,0],10,[4]],[[10,3,1,6],10,[7,4,2,10,9],2]],[0,[[8,3,6,8],2],[4,9,[1,9,2],6,[10]],9,4]]
[[[[],[1,2],5,4],4,[8,9]],[5,2],[1,9,[6,[7,1,5,3],7,[0,1,2,5,0]]],[6,[2,10,4,[10,6,2,6]],[],[[]],1],[[[1,6,1],[9],7,[10,7,9]],[5,7,5,8,[4,6,3,7,4]],1,10,[]]]
[[],[[[5],[6,0,2],2]],[9,[[9,3],1,2],[6,[1],0,[]],[[0,7]],[[5,1,6,9,10],10,[],1,7]],[[[],[8,8,1,3,2],2,8],10],[10,[4,5,[2,2,1,5,3],5],1,[[],9,7,9],[6,[],9,[],7]]]
[[7],[[[4,6,1,5],1,[4,1,1,7,8]],[4,4]],[9,0,7,[3,10,[10,6,9],3,[2]]],[[8],[[],[8,4,9,1]],[6,[5,7,7,8],10],3],[[],8,8,0,10]]
[[0,7]]
[[[5,[2],[0,0,9,10]],7],[4,[[2,2,4,0]],[10,[10,5,6,0,1],8],4,3],[[[1,1,10,7,3],[1,3,0,1,8],[]],[],[[],[2],6,9],[[7,10],4,[0,3,6,7,6],[1,10,6,4,6],9],3],[6]]
[[[7],[],[[]],[3]],[4,3,10,[]],[9],[],[[6,6,5],0,4,3]]
[[8,[[1],5,[6,1,5,2],10,[0,1,7,4,9]],10,[[8,2,3,4]]],[[[],0,4,6,0],5,3],[],[],[]]
[[4,[[1],[10,0,8,8,7],6,9],10,0],[[[8,3],7,[10,6,2,9,7],8],[[7,2,10,1],[7,0],[3,7,5],10]],[0,7]]
[[[1]],[7,[[8,4],8,3],4,[6,6],1],[3,[1]],[]]
[[1,[9]],[]]
[[],[[]]]
[[0],[[3,4,[9,7,0,10,3],8,1]]]
[[[7,[6,7,10]],[0,3,4]]]
[[3,10,4,[[6,5,4]]]]
[[[[1]],[[2,3],9,[3,9,8]],9,3],[[10,[1,5,8,1]],3,[9,10,[5,1,9,1,7],0]],[4],[7,[4,10,[]]]]
[[8]]
[[1,2],[],[6,[9,[4,8,0,1]],[[9,7],8,7],[[6,5,1,5],[8,0,5]]]]
[[[],[],3,0,[[1,1],0,[2,3,5],0]],[3,10,9,4,9],[],[[0,[7],[4],9],0,2,6]]
[[],[],[[[0,2,2,1],10,[5,8]],[0,6,[3,0,3,7]],[4,[1,6,5,7]]],[[],[[]]]]
[[9,9,8,3]]
[[]]
[[0,[[]],[[10,1,10]],[[0,10,1,10,9],8],3],[[[9,5,5],9,8,[3,4],[0,10,3,10,10]],[3,10]]]
[[],[[[7,6],2]]]
[[[5,8,2,8,9],[[4,9,2,6,5]],9],[[4,9,[6,4]],[[],3,[],[],[7,7]],[],1],[],[],[[[]]]]
[[],[[6,[0,1,10,4],[7,8,5,7,4],[10],[7,3,5,10]],0],[[],[1],[[1,5,6],1,10,7],[[0,5,6,4,10],[3,10,10,4]]],[6],[]]
[[[4,7,[0],[8,1,1],7],9,[[0,10],1,10,4,[]]],[3,[7],0]]
[[8,[7,0,[6,6,0,4,2],[0,4,6,9],9]]]
[[2,9,[[8,0,4],10,[9,0,9,7,3]]]]
[[[[],[],[3]],9],[[8,0],9,[8]],[[3,10,5,[4,3,10,0],0],[[0],0,[4,1,9,0,6],9],9,[],[[]]],[]]
[[0],[1,[1,5,[6]],[[5,4],1,2,[8,2,8,4],[7,6,5,3]],2],[6]]
[[[[5,10,5,9,10],0],[[9],7,2,1,[]]],[[6,[8]],[[8,3,4],[8],[7,8,7,8]],6,9]]
[[6,[[5,10,8]]],[[9,[],6],9,2,[[3,1,10],[4,5,0],[0],[2,1,8,6]]],[4],[[[10,10,5,0,0],5,8]],[4]]
[[8,[]]]
[[7,5],[6,[[]]],[5,7],[]]
[[],[[9,[],1],[],10,6,[[1],6,[10,7,6],7]],[[7,10,8,7],0],[[[],3,[6,8,7]],[[7,5,6,1,2],[1,7,10,5,8]],10,0,[[9,1,1,7]]]]
[[2,7,6,[[2,7,9],5,9]]]
[[0,6,0,[],6],[]]
[[[9],[8,10]]]
[[3,9,[1,7,3],7],[]]
[[1,[1,2,[2,2,5,3,4],[4,7,10]],[[3,0]],[2]]]
[[[[9,2,4,1],2,[4]]],[[8,[3,3,6,10],[4,1,10,5,3],2],6,7,[8,[0,8,4,0]],8],[[5,7,[7,3,1,5,2]],[2,4,0,0]],[[10,[],[1,2,6],5],6]]
[[7],[6]]
[[4],[8,[[9,7],5,[2,7,4,1],10],[[6,6,9],5],[]],[4,[]],[[[6,6,2],[],[7,10,2,2,7]],[0],4]]
[[[[6,5,2]],[[1,7,10,8],[],8,[4,2,6,5,5]],4,[[5,10,2,9,7],[5,8,2],0,[1,3]]]]
[[],[[4,[1,4,4]],[6,9,8,9,2],6],[]]
[[[5],[0,[9,4,5],[1,3,10,1]],3,2],[[[6,9],[1,4,0,10,10]],7,4,9],[],[[],4]]
[[[[6,7,1,1],8,9,[0,8,3,1,3],1],[],5],[[[2,3],[0,3,9,7],[1,7],1,[8]],6,3,[8],6],[[[7,6,5,0,6],6,3,5],[[10,9,1,3],[7,3,9],8,8],[3],8,[[5,7,2,5,10]]],[2,2,[[2],[3],[1,0,2,5,3],[10,0],[3,7]],8],[8]]
[[7,[9,7]],[2],[[],6],[[7,7],9,9,[[0,4,5,10,2],3]]]
[[[7,[3,8,10]],[[9,8,0,8,1],4,7],10],[]]
[[5,[[4,9,2,0,10],10,9,2,0],[[6,1]]],[8,[],[5],9]]
[[[],0],[],[0],[4]]
[[],[],[]]
[[10,8],[1,[5,[9,9,5]],1,[[4,8,10],10,8]]]
[[[2,3,9,3,[2,8]],6],[2,10],[[[2,10],9,1,5],[6,[],[1,0,2,10,8],5],10],[4]]

164
inputs/day14.txt Normal file
View File

@@ -0,0 +1,164 @@
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
513,69 -> 513,71 -> 511,71 -> 511,76 -> 522,76 -> 522,71 -> 517,71 -> 517,69
520,87 -> 524,87
480,121 -> 480,122 -> 498,122 -> 498,121
520,56 -> 520,60 -> 517,60 -> 517,66 -> 528,66 -> 528,60 -> 523,60 -> 523,56
484,147 -> 484,149 -> 483,149 -> 483,153 -> 489,153 -> 489,149 -> 488,149 -> 488,147
493,24 -> 498,24
496,22 -> 501,22
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
480,118 -> 480,111 -> 480,118 -> 482,118 -> 482,116 -> 482,118 -> 484,118 -> 484,111 -> 484,118 -> 486,118 -> 486,110 -> 486,118 -> 488,118 -> 488,117 -> 488,118
508,79 -> 512,79
486,104 -> 486,105 -> 493,105 -> 493,104
497,129 -> 502,129
474,34 -> 478,34
480,118 -> 480,111 -> 480,118 -> 482,118 -> 482,116 -> 482,118 -> 484,118 -> 484,111 -> 484,118 -> 486,118 -> 486,110 -> 486,118 -> 488,118 -> 488,117 -> 488,118
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
508,87 -> 512,87
512,53 -> 512,43 -> 512,53 -> 514,53 -> 514,48 -> 514,53 -> 516,53 -> 516,44 -> 516,53 -> 518,53 -> 518,50 -> 518,53 -> 520,53 -> 520,46 -> 520,53
499,20 -> 504,20
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
480,118 -> 480,111 -> 480,118 -> 482,118 -> 482,116 -> 482,118 -> 484,118 -> 484,111 -> 484,118 -> 486,118 -> 486,110 -> 486,118 -> 488,118 -> 488,117 -> 488,118
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
496,125 -> 501,125
512,53 -> 512,43 -> 512,53 -> 514,53 -> 514,48 -> 514,53 -> 516,53 -> 516,44 -> 516,53 -> 518,53 -> 518,50 -> 518,53 -> 520,53 -> 520,46 -> 520,53
511,26 -> 516,26
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
520,56 -> 520,60 -> 517,60 -> 517,66 -> 528,66 -> 528,60 -> 523,60 -> 523,56
520,56 -> 520,60 -> 517,60 -> 517,66 -> 528,66 -> 528,60 -> 523,60 -> 523,56
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
502,83 -> 506,83
496,87 -> 500,87
483,26 -> 488,26
487,131 -> 492,131
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
499,85 -> 503,85
480,34 -> 484,34
474,38 -> 478,38
486,104 -> 486,105 -> 493,105 -> 493,104
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
494,90 -> 494,92 -> 489,92 -> 489,100 -> 504,100 -> 504,92 -> 497,92 -> 497,90
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
513,69 -> 513,71 -> 511,71 -> 511,76 -> 522,76 -> 522,71 -> 517,71 -> 517,69
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
520,56 -> 520,60 -> 517,60 -> 517,66 -> 528,66 -> 528,60 -> 523,60 -> 523,56
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
480,38 -> 484,38
489,40 -> 493,40
483,36 -> 487,36
480,118 -> 480,111 -> 480,118 -> 482,118 -> 482,116 -> 482,118 -> 484,118 -> 484,111 -> 484,118 -> 486,118 -> 486,110 -> 486,118 -> 488,118 -> 488,117 -> 488,118
508,131 -> 513,131
517,85 -> 521,85
494,131 -> 499,131
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
512,53 -> 512,43 -> 512,53 -> 514,53 -> 514,48 -> 514,53 -> 516,53 -> 516,44 -> 516,53 -> 518,53 -> 518,50 -> 518,53 -> 520,53 -> 520,46 -> 520,53
494,90 -> 494,92 -> 489,92 -> 489,100 -> 504,100 -> 504,92 -> 497,92 -> 497,90
514,87 -> 518,87
512,53 -> 512,43 -> 512,53 -> 514,53 -> 514,48 -> 514,53 -> 516,53 -> 516,44 -> 516,53 -> 518,53 -> 518,50 -> 518,53 -> 520,53 -> 520,46 -> 520,53
512,53 -> 512,43 -> 512,53 -> 514,53 -> 514,48 -> 514,53 -> 516,53 -> 516,44 -> 516,53 -> 518,53 -> 518,50 -> 518,53 -> 520,53 -> 520,46 -> 520,53
494,90 -> 494,92 -> 489,92 -> 489,100 -> 504,100 -> 504,92 -> 497,92 -> 497,90
507,24 -> 512,24
512,53 -> 512,43 -> 512,53 -> 514,53 -> 514,48 -> 514,53 -> 516,53 -> 516,44 -> 516,53 -> 518,53 -> 518,50 -> 518,53 -> 520,53 -> 520,46 -> 520,53
471,40 -> 475,40
480,118 -> 480,111 -> 480,118 -> 482,118 -> 482,116 -> 482,118 -> 484,118 -> 484,111 -> 484,118 -> 486,118 -> 486,110 -> 486,118 -> 488,118 -> 488,117 -> 488,118
511,81 -> 515,81
514,83 -> 518,83
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
512,53 -> 512,43 -> 512,53 -> 514,53 -> 514,48 -> 514,53 -> 516,53 -> 516,44 -> 516,53 -> 518,53 -> 518,50 -> 518,53 -> 520,53 -> 520,46 -> 520,53
465,40 -> 469,40
512,53 -> 512,43 -> 512,53 -> 514,53 -> 514,48 -> 514,53 -> 516,53 -> 516,44 -> 516,53 -> 518,53 -> 518,50 -> 518,53 -> 520,53 -> 520,46 -> 520,53
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
480,29 -> 490,29 -> 490,28
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
493,127 -> 498,127
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
504,26 -> 509,26
492,20 -> 497,20
477,36 -> 481,36
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
505,81 -> 509,81
512,53 -> 512,43 -> 512,53 -> 514,53 -> 514,48 -> 514,53 -> 516,53 -> 516,44 -> 516,53 -> 518,53 -> 518,50 -> 518,53 -> 520,53 -> 520,46 -> 520,53
513,69 -> 513,71 -> 511,71 -> 511,76 -> 522,76 -> 522,71 -> 517,71 -> 517,69
480,121 -> 480,122 -> 498,122 -> 498,121
494,90 -> 494,92 -> 489,92 -> 489,100 -> 504,100 -> 504,92 -> 497,92 -> 497,90
512,53 -> 512,43 -> 512,53 -> 514,53 -> 514,48 -> 514,53 -> 516,53 -> 516,44 -> 516,53 -> 518,53 -> 518,50 -> 518,53 -> 520,53 -> 520,46 -> 520,53
512,53 -> 512,43 -> 512,53 -> 514,53 -> 514,48 -> 514,53 -> 516,53 -> 516,44 -> 516,53 -> 518,53 -> 518,50 -> 518,53 -> 520,53 -> 520,46 -> 520,53
490,26 -> 495,26
504,129 -> 509,129
484,147 -> 484,149 -> 483,149 -> 483,153 -> 489,153 -> 489,149 -> 488,149 -> 488,147
484,147 -> 484,149 -> 483,149 -> 483,153 -> 489,153 -> 489,149 -> 488,149 -> 488,147
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
513,69 -> 513,71 -> 511,71 -> 511,76 -> 522,76 -> 522,71 -> 517,71 -> 517,69
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
503,22 -> 508,22
495,18 -> 500,18
490,129 -> 495,129
477,40 -> 481,40
520,56 -> 520,60 -> 517,60 -> 517,66 -> 528,66 -> 528,60 -> 523,60 -> 523,56
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
511,85 -> 515,85
502,87 -> 506,87
513,69 -> 513,71 -> 511,71 -> 511,76 -> 522,76 -> 522,71 -> 517,71 -> 517,69
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
500,127 -> 505,127
489,22 -> 494,22
499,14 -> 499,15 -> 508,15
480,118 -> 480,111 -> 480,118 -> 482,118 -> 482,116 -> 482,118 -> 484,118 -> 484,111 -> 484,118 -> 486,118 -> 486,110 -> 486,118 -> 488,118 -> 488,117 -> 488,118
483,40 -> 487,40
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
484,147 -> 484,149 -> 483,149 -> 483,153 -> 489,153 -> 489,149 -> 488,149 -> 488,147
480,118 -> 480,111 -> 480,118 -> 482,118 -> 482,116 -> 482,118 -> 484,118 -> 484,111 -> 484,118 -> 486,118 -> 486,110 -> 486,118 -> 488,118 -> 488,117 -> 488,118
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
497,26 -> 502,26
512,53 -> 512,43 -> 512,53 -> 514,53 -> 514,48 -> 514,53 -> 516,53 -> 516,44 -> 516,53 -> 518,53 -> 518,50 -> 518,53 -> 520,53 -> 520,46 -> 520,53
501,131 -> 506,131
468,38 -> 472,38
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
486,24 -> 491,24
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
480,118 -> 480,111 -> 480,118 -> 482,118 -> 482,116 -> 482,118 -> 484,118 -> 484,111 -> 484,118 -> 486,118 -> 486,110 -> 486,118 -> 488,118 -> 488,117 -> 488,118
471,36 -> 475,36
480,118 -> 480,111 -> 480,118 -> 482,118 -> 482,116 -> 482,118 -> 484,118 -> 484,111 -> 484,118 -> 486,118 -> 486,110 -> 486,118 -> 488,118 -> 488,117 -> 488,118
494,90 -> 494,92 -> 489,92 -> 489,100 -> 504,100 -> 504,92 -> 497,92 -> 497,90
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
512,53 -> 512,43 -> 512,53 -> 514,53 -> 514,48 -> 514,53 -> 516,53 -> 516,44 -> 516,53 -> 518,53 -> 518,50 -> 518,53 -> 520,53 -> 520,46 -> 520,53
484,147 -> 484,149 -> 483,149 -> 483,153 -> 489,153 -> 489,149 -> 488,149 -> 488,147
480,118 -> 480,111 -> 480,118 -> 482,118 -> 482,116 -> 482,118 -> 484,118 -> 484,111 -> 484,118 -> 486,118 -> 486,110 -> 486,118 -> 488,118 -> 488,117 -> 488,118
486,38 -> 490,38
513,69 -> 513,71 -> 511,71 -> 511,76 -> 522,76 -> 522,71 -> 517,71 -> 517,69
480,118 -> 480,111 -> 480,118 -> 482,118 -> 482,116 -> 482,118 -> 484,118 -> 484,111 -> 484,118 -> 486,118 -> 486,110 -> 486,118 -> 488,118 -> 488,117 -> 488,118
508,83 -> 512,83
512,53 -> 512,43 -> 512,53 -> 514,53 -> 514,48 -> 514,53 -> 516,53 -> 516,44 -> 516,53 -> 518,53 -> 518,50 -> 518,53 -> 520,53 -> 520,46 -> 520,53
486,104 -> 486,105 -> 493,105 -> 493,104
480,118 -> 480,111 -> 480,118 -> 482,118 -> 482,116 -> 482,118 -> 484,118 -> 484,111 -> 484,118 -> 486,118 -> 486,110 -> 486,118 -> 488,118 -> 488,117 -> 488,118
484,147 -> 484,149 -> 483,149 -> 483,153 -> 489,153 -> 489,149 -> 488,149 -> 488,147
480,29 -> 490,29 -> 490,28
484,147 -> 484,149 -> 483,149 -> 483,153 -> 489,153 -> 489,149 -> 488,149 -> 488,147
480,121 -> 480,122 -> 498,122 -> 498,121
500,24 -> 505,24
520,56 -> 520,60 -> 517,60 -> 517,66 -> 528,66 -> 528,60 -> 523,60 -> 523,56
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
494,90 -> 494,92 -> 489,92 -> 489,100 -> 504,100 -> 504,92 -> 497,92 -> 497,90
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
480,118 -> 480,111 -> 480,118 -> 482,118 -> 482,116 -> 482,118 -> 484,118 -> 484,111 -> 484,118 -> 486,118 -> 486,110 -> 486,118 -> 488,118 -> 488,117 -> 488,118
480,118 -> 480,111 -> 480,118 -> 482,118 -> 482,116 -> 482,118 -> 484,118 -> 484,111 -> 484,118 -> 486,118 -> 486,110 -> 486,118 -> 488,118 -> 488,117 -> 488,118
475,166 -> 475,159 -> 475,166 -> 477,166 -> 477,156 -> 477,166 -> 479,166 -> 479,165 -> 479,166 -> 481,166 -> 481,156 -> 481,166 -> 483,166 -> 483,163 -> 483,166 -> 485,166 -> 485,156 -> 485,166 -> 487,166 -> 487,159 -> 487,166
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
499,14 -> 499,15 -> 508,15
513,69 -> 513,71 -> 511,71 -> 511,76 -> 522,76 -> 522,71 -> 517,71 -> 517,69
494,90 -> 494,92 -> 489,92 -> 489,100 -> 504,100 -> 504,92 -> 497,92 -> 497,90
477,32 -> 481,32
471,144 -> 471,134 -> 471,144 -> 473,144 -> 473,140 -> 473,144 -> 475,144 -> 475,143 -> 475,144 -> 477,144 -> 477,142 -> 477,144 -> 479,144 -> 479,137 -> 479,144 -> 481,144 -> 481,134 -> 481,144 -> 483,144 -> 483,136 -> 483,144 -> 485,144 -> 485,134 -> 485,144
505,85 -> 509,85
520,56 -> 520,60 -> 517,60 -> 517,66 -> 528,66 -> 528,60 -> 523,60 -> 523,56

34
inputs/day15.txt Normal file
View File

@@ -0,0 +1,34 @@
Sensor at x=1363026, y=2928920: closest beacon is at x=1571469, y=3023534
Sensor at x=2744178, y=3005943: closest beacon is at x=3091714, y=3106683
Sensor at x=223983, y=2437431: closest beacon is at x=-278961, y=3326224
Sensor at x=2454616, y=2576344: closest beacon is at x=2885998, y=2387754
Sensor at x=1551436, y=29248: closest beacon is at x=1865296, y=-1279130
Sensor at x=2997120, y=2493979: closest beacon is at x=2885998, y=2387754
Sensor at x=1588355, y=3153332: closest beacon is at x=1571469, y=3023534
Sensor at x=3539081, y=3302128: closest beacon is at x=3309042, y=3583067
Sensor at x=3973905, y=60392: closest beacon is at x=3515381, y=-806927
Sensor at x=3305001, y=3120691: closest beacon is at x=3091714, y=3106683
Sensor at x=3859262, y=2668840: closest beacon is at x=3574747, y=2000000
Sensor at x=2475557, y=3997856: closest beacon is at x=2364210, y=4052453
Sensor at x=2775306, y=3668540: closest beacon is at x=3309042, y=3583067
Sensor at x=3018235, y=2285225: closest beacon is at x=2885998, y=2387754
Sensor at x=3033163, y=3294719: closest beacon is at x=3091714, y=3106683
Sensor at x=3079956, y=3215569: closest beacon is at x=3091714, y=3106683
Sensor at x=3994355, y=1831842: closest beacon is at x=3574747, y=2000000
Sensor at x=1741021, y=3231978: closest beacon is at x=1571469, y=3023534
Sensor at x=1873455, y=3917294: closest beacon is at x=2364210, y=4052453
Sensor at x=3128140, y=2938277: closest beacon is at x=3091714, y=3106683
Sensor at x=732217, y=3603298: closest beacon is at x=-278961, y=3326224
Sensor at x=3884431, y=3834735: closest beacon is at x=3309042, y=3583067
Sensor at x=3679358, y=1029949: closest beacon is at x=3574747, y=2000000
Sensor at x=2260133, y=3563353: closest beacon is at x=2364210, y=4052453
Sensor at x=60149, y=3320681: closest beacon is at x=-278961, y=3326224
Sensor at x=3132535, y=2405693: closest beacon is at x=2885998, y=2387754
Sensor at x=3028313, y=2829410: closest beacon is at x=3091714, y=3106683
Sensor at x=3142423, y=3921417: closest beacon is at x=3309042, y=3583067
Sensor at x=2636416, y=939525: closest beacon is at x=2885998, y=2387754
Sensor at x=524530, y=681397: closest beacon is at x=-1031499, y=681463
Sensor at x=3155000, y=1666362: closest beacon is at x=3574747, y=2000000
Sensor at x=2169350, y=3040469: closest beacon is at x=1571469, y=3023534
Sensor at x=1663350, y=1595182: closest beacon is at x=1571469, y=3023534
Sensor at x=3311582, y=3386773: closest beacon is at x=3309042, y=3583067

55
inputs/day16.txt Normal file
View File

@@ -0,0 +1,55 @@
Valve NA has flow rate=0; tunnels lead to valves MU, PH
Valve NW has flow rate=0; tunnels lead to valves KB, MH
Valve MR has flow rate=0; tunnels lead to valves GC, FI
Valve XD has flow rate=0; tunnels lead to valves UN, CN
Valve HK has flow rate=0; tunnels lead to valves AA, IF
Valve JL has flow rate=0; tunnels lead to valves IF, WB
Valve RQ has flow rate=13; tunnels lead to valves BL, DJ
Valve AB has flow rate=0; tunnels lead to valves BO, RU
Valve PE has flow rate=0; tunnels lead to valves AZ, IF
Valve QF has flow rate=0; tunnels lead to valves TD, AZ
Valve BA has flow rate=0; tunnels lead to valves RF, GU
Valve SY has flow rate=0; tunnels lead to valves MH, MU
Valve NT has flow rate=0; tunnels lead to valves DJ, UN
Valve GU has flow rate=21; tunnels lead to valves VJ, BA, YP
Valve AZ has flow rate=12; tunnels lead to valves QF, PI, AS, PE
Valve WQ has flow rate=23; tunnels lead to valves VJ, UM, CN
Valve DR has flow rate=0; tunnels lead to valves GA, CQ
Valve UM has flow rate=0; tunnels lead to valves IE, WQ
Valve XI has flow rate=0; tunnels lead to valves IE, IF
Valve SS has flow rate=0; tunnels lead to valves CQ, MH
Valve IE has flow rate=22; tunnels lead to valves YP, UM, XI, XA
Valve BT has flow rate=24; tunnels lead to valves KB, BL, GA
Valve GA has flow rate=0; tunnels lead to valves DR, BT
Valve AR has flow rate=0; tunnels lead to valves IF, FI
Valve DJ has flow rate=0; tunnels lead to valves RQ, NT
Valve PI has flow rate=0; tunnels lead to valves FI, AZ
Valve WB has flow rate=0; tunnels lead to valves TD, JL
Valve OQ has flow rate=0; tunnels lead to valves ME, TD
Valve RU has flow rate=19; tunnel leads to valve AB
Valve IF has flow rate=7; tunnels lead to valves AR, JL, HK, PE, XI
Valve BO has flow rate=0; tunnels lead to valves ME, AB
Valve CN has flow rate=0; tunnels lead to valves WQ, XD
Valve HH has flow rate=0; tunnels lead to valves AA, FS
Valve AS has flow rate=0; tunnels lead to valves AA, AZ
Valve FS has flow rate=0; tunnels lead to valves HH, MH
Valve PQ has flow rate=0; tunnels lead to valves TD, AA
Valve AA has flow rate=0; tunnels lead to valves HH, CO, AS, HK, PQ
Valve ME has flow rate=18; tunnels lead to valves OQ, BO, PH
Valve RF has flow rate=0; tunnels lead to valves UN, BA
Valve MH has flow rate=8; tunnels lead to valves FS, NW, SS, SY
Valve YP has flow rate=0; tunnels lead to valves IE, GU
Valve FI has flow rate=11; tunnels lead to valves PI, MR, AR, CO, DI
Valve UU has flow rate=0; tunnels lead to valves CQ, MU
Valve CO has flow rate=0; tunnels lead to valves AA, FI
Valve TD has flow rate=16; tunnels lead to valves QF, GC, OQ, WB, PQ
Valve MU has flow rate=15; tunnels lead to valves SY, UU, NA
Valve BL has flow rate=0; tunnels lead to valves BT, RQ
Valve PH has flow rate=0; tunnels lead to valves ME, NA
Valve XA has flow rate=0; tunnels lead to valves IE, DI
Valve GC has flow rate=0; tunnels lead to valves TD, MR
Valve KB has flow rate=0; tunnels lead to valves BT, NW
Valve DI has flow rate=0; tunnels lead to valves XA, FI
Valve CQ has flow rate=9; tunnels lead to valves UU, DR, SS
Valve VJ has flow rate=0; tunnels lead to valves WQ, GU
Valve UN has flow rate=20; tunnels lead to valves NT, XD, RF

1
inputs/day17.txt Normal file

File diff suppressed because one or more lines are too long

2145
inputs/day18.txt Normal file

File diff suppressed because it is too large Load Diff

30
inputs/day19.txt Normal file
View File

@@ -0,0 +1,30 @@
Blueprint 1: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 7 clay. Each geode robot costs 2 ore and 19 obsidian.
Blueprint 2: Each ore robot costs 2 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 20 clay. Each geode robot costs 4 ore and 18 obsidian.
Blueprint 3: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 20 clay. Each geode robot costs 2 ore and 10 obsidian.
Blueprint 4: Each ore robot costs 3 ore. Each clay robot costs 4 ore. Each obsidian robot costs 2 ore and 19 clay. Each geode robot costs 2 ore and 12 obsidian.
Blueprint 5: Each ore robot costs 3 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 20 clay. Each geode robot costs 3 ore and 14 obsidian.
Blueprint 6: Each ore robot costs 3 ore. Each clay robot costs 4 ore. Each obsidian robot costs 2 ore and 15 clay. Each geode robot costs 3 ore and 7 obsidian.
Blueprint 7: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 19 clay. Each geode robot costs 2 ore and 20 obsidian.
Blueprint 8: Each ore robot costs 2 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 13 clay. Each geode robot costs 2 ore and 20 obsidian.
Blueprint 9: Each ore robot costs 2 ore. Each clay robot costs 2 ore. Each obsidian robot costs 2 ore and 8 clay. Each geode robot costs 2 ore and 14 obsidian.
Blueprint 10: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 2 ore and 11 clay. Each geode robot costs 3 ore and 14 obsidian.
Blueprint 11: Each ore robot costs 3 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 5 clay. Each geode robot costs 4 ore and 8 obsidian.
Blueprint 12: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 16 clay. Each geode robot costs 2 ore and 18 obsidian.
Blueprint 13: Each ore robot costs 3 ore. Each clay robot costs 4 ore. Each obsidian robot costs 2 ore and 11 clay. Each geode robot costs 2 ore and 10 obsidian.
Blueprint 14: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 2 ore and 14 clay. Each geode robot costs 3 ore and 17 obsidian.
Blueprint 15: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 19 clay. Each geode robot costs 3 ore and 17 obsidian.
Blueprint 16: Each ore robot costs 2 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 20 clay. Each geode robot costs 2 ore and 17 obsidian.
Blueprint 17: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 14 clay. Each geode robot costs 4 ore and 8 obsidian.
Blueprint 18: Each ore robot costs 2 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 9 clay. Each geode robot costs 3 ore and 9 obsidian.
Blueprint 19: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 2 ore and 10 clay. Each geode robot costs 3 ore and 14 obsidian.
Blueprint 20: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 13 clay. Each geode robot costs 3 ore and 12 obsidian.
Blueprint 21: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 4 ore and 15 clay. Each geode robot costs 4 ore and 9 obsidian.
Blueprint 22: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 20 clay. Each geode robot costs 2 ore and 12 obsidian.
Blueprint 23: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 4 ore and 19 clay. Each geode robot costs 4 ore and 12 obsidian.
Blueprint 24: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 15 clay. Each geode robot costs 3 ore and 8 obsidian.
Blueprint 25: Each ore robot costs 2 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 11 clay. Each geode robot costs 2 ore and 16 obsidian.
Blueprint 26: Each ore robot costs 3 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 17 clay. Each geode robot costs 3 ore and 7 obsidian.
Blueprint 27: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 7 clay. Each geode robot costs 3 ore and 20 obsidian.
Blueprint 28: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 10 clay. Each geode robot costs 2 ore and 10 obsidian.
Blueprint 29: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 17 clay. Each geode robot costs 2 ore and 13 obsidian.
Blueprint 30: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 4 ore and 20 clay. Each geode robot costs 4 ore and 8 obsidian.

5000
inputs/day20.txt Normal file

File diff suppressed because it is too large Load Diff

2399
inputs/day21.txt Normal file

File diff suppressed because it is too large Load Diff

202
inputs/day22.txt Normal file

File diff suppressed because one or more lines are too long

71
inputs/day23.txt Normal file
View File

@@ -0,0 +1,71 @@
...####..#.#.#....###..#....#..#..#...##..###..##.#...######.##....####
..#.##..#.#...###..###.##....#..##......#.###..###....#.#.#....#...#.#.
.##...#...####..####....#....#####.##.#.....#.#.#.#..#..#...####....###
.####..#.##...#.##..#.#...#..#..##.######.#######.###.##.....####.#.##.
##.##.#..######.####..##...##.#.##...###.###..#.#..####..##...###.##.#.
...###.#.###..####..###.##..#..###..#..##.###.##.##....##...##.#.#..##.
###.##...#...#.#..####..##.#..###.##..#..##.#...#...##..##..##.##.###.#
..##....###.##.#...#####.#.#.###.#.#.#.##.#...#####.#####.....###.....#
#.####.#...#.#...##..#..#.#...###.#.####.#..##..##.#.###...#.####....##
#.##...#.#####...##....##..###..#...##.###..#.#.##.##.....#####....#...
#...#..#..#.#...##..#####.#.###......##..##.##.##...###..###...#..###..
..#.##.#..##.##.####.....#.###..#..#..#...###.###..#.#.##.##..#####..##
.##.#...#.....####......#.#..#..#.#....#.#...####...##.#.#.....#.#.....
#..#.##..###..#.....#.###..#.#..........##.......##.##.#..######...###.
.#...##.#.#...##.####..######.###.#.#.#.####.##.###..#...###.#..#..##.#
#.#.##.#.###..##.###.##.....###.#.#...#...###.##.#.#.##.##.#####.....#.
.#...###.##...#.##.#.###.###.##......##...##.#.###..#..#.#.##...####.#.
.#.#.##..#...#.##..#..##.....#....#....#.###....#########..#.#.########
.#.##..###..##..#.......##.##..#..###.#.##.####....#..#.#...##..##.#...
#####.##.#.....#.##...#.#...#.#.####..####....#.#...#.....###...##.....
..###....#....##...#.#...###....##.###.#.#...##..##.#..#.##....#.#.#.##
########..####...#.#..##.###...##.#...#...#.######...#..#..#..#...#..##
#.#....##...##..#...#....#.##....#.###.##.#...###.#..#.#.#...###..#.#.#
#.##........#..##...#...##.##.###.#.##...##...#####.#.#.....####.#.#..#
##.##...####.##.#...#....#...###.#...#....#.#.#.####...#.#....#.####.#.
.###....#..#.#..#..####..###.#.#..#.#..#.####..#####..#.#.#..#.....##.#
.#####.#.##.###......#..##.#.....#######..##.##.#####....#..#.#..####.#
.#....###....#.##..##.#.#.#.....#####..#.#.#.##...#.#....#.##..##....#.
####....####...#.#...#..##....#.#.#.###..#.######.##..##..######...#.#.
.#..####..#####.###..#..##.#.####.##.##..#.###..#...##.#...#.#.#.#.#.##
#.###########.####.....###.#..#...###.#######...#.#...##..###....#....#
#..#.####...###..####.#.##.#.#.#.#####.###.####...#...#....########..#.
#######.#..#.#..####.##.##..##.#...##..#######..#.#..#...#..##..#.###.#
##.#.....###.#..####.##..#.#######.#.#..#.##.#..###.##..##.##.#...#.#.#
#.#######.#.##.#.###.##.##...##..#.#....#.#.#..#.#..###..##.#.#.....##.
.##.##.#...####.#####.####.####.....#..####..#..##..###...#.#.###.#...#
.####...#..#.#.#.#........#..###...#####..####..##..######.###...#####.
###....#..##.##..#####....##.#..#...##.#####..#..###.#####..###.#..##.#
..#.#...#.##..#.##.####.####..#######....##....#.#....#.#.#..##.#.#..##
.#..#.########.........###.#.....###.######..#.######...####..#..#.#.##
.#.#...###...#.#.#.#..#...##.###.#.#.##.##.....####......##.#.#....##.#
..##..##...#.#######.#.##.####.###.#..#.....#.#..#...#..####..##..#.###
.#...####.##....###..#.###...###.##...###..######.#.#.#.#.#.#.#....#.##
.###..#.###.###..##.#..##..#.#.#...#..#.#..#...##..#..#...###...#####.#
#.#..#.#.#.....##..#.##..##.#.....#..###..#.#.#.#.#.#.##..#.####..##...
..#.#.####...#.##..##.##.####..##.#.#..##.#.###.#.######..#.######.#...
###.#.#.#.####..##.######.#.#...##......###..###.#..#...#...#.#..######
.###.#..#..######..##.####.###..##.#...#.#.#......###..##.#.#....#.#.#.
.##..#...#....#..###.##.#..#####.#.#....######..#....#..######.....#...
#.#...#..#.##...#..#..###.......####...#.####...#.#.#....#####.##...#.#
....#.####.#...#..#####.#..###..######.###.....#..#.#.#.#.#.##.#.##....
#.......#####.#.###..##.###..#####..#.###..#.....#.###.###..###..#.##.#
##.#.#....##.#.#..#..#...###.#..#.....###...###...#..#.######.#.#...##.
#....####.##.###....#....#....#...#..####...#.#.#.###..##.#.#..##.#..##
#.....#.##....###..####..##.#.......#..#.#.#.....#....####.#...#....###
###.#..####....#.....#..####....######.....#.#....#..###.#.#..#.#..###.
#..#.#.#...##....##.##....##.....#..####.###..##.#.#.##..#.##.###...###
....###.#.#.#..###.#.##.#.#.#.#####.#####..#..##...##.##.#...####.#.###
#####.....#.#.#.#.#.#.###.#####.#...#.##..#.#.##..##..###...#...#..##..
##.####.#.#.##..##.##.###....##.#..###.####..#######.#...##....#..##.##
##..#.####.##..#..#.#.#####.#.#.....#####..##..#.##.....##..#.#....##.#
.#..####...####.#####.##..#.##.....###.###.#.#.######..####.#...#..#.#.
##.####..##..#.....##.#.####..#..#....##...#....#####..##########.###.#
#...#.#.....#####.......###.#.#.#.###....#.#..#..#.##..#..#..#.####.###
##.###..#..##......##########....###..#######..#....#.#..###.##........
####.........#.#...##.#.#.#..#.#.####.#####....##...#.#.##.###..#.##.##
.####.#...#..#.##.####..##..#..#...##...........##..###.####..##..#.#..
.#####.##....##.#..####.##..##.#.###.....##.#..#..#.#.#...#.#...####...
#...####........#.##.####..##.....#####.#.#####.#####..#.##.#..##...##.
.###..###.####..###..##..##.#..##.###.#...#..#...#..#...#..#######.#.##
.#..#..##...##....##....####..#....#.##.....#.##..#.#..#...#..##.#..#.#

8
src/bin/day12_1.rs Normal file
View File

@@ -0,0 +1,8 @@
use std::fs;
use aoc2022::day12::process_part_1;
fn main() {
let file = fs::read_to_string("./inputs/day12.txt").unwrap();
println!("{}", process_part_1(&file));
}

8
src/bin/day12_2.rs Normal file
View File

@@ -0,0 +1,8 @@
use std::fs;
use aoc2022::day12::process_part_2;
fn main() {
let file = fs::read_to_string("./inputs/day12.txt").unwrap();
println!("{}", process_part_2(&file));
}

8
src/bin/day13_1.rs Normal file
View File

@@ -0,0 +1,8 @@
use std::fs;
use aoc2022::day13::process_part_1;
fn main() {
let file = fs::read_to_string("./inputs/day13.txt").unwrap();
println!("{}", process_part_1(&file));
}

8
src/bin/day13_2.rs Normal file
View File

@@ -0,0 +1,8 @@
use std::fs;
use aoc2022::day13::process_part_2;
fn main() {
let file = fs::read_to_string("./inputs/day13.txt").unwrap();
println!("{}", process_part_2(&file));
}

8
src/bin/day14_1.rs Normal file
View File

@@ -0,0 +1,8 @@
use std::fs;
use aoc2022::day14::process_part_1;
fn main() {
let file = fs::read_to_string("./inputs/day14.txt").unwrap();
println!("{}", process_part_1(&file));
}

8
src/bin/day14_2.rs Normal file
View File

@@ -0,0 +1,8 @@
use std::fs;
use aoc2022::day14::process_part_2;
fn main() {
let file = fs::read_to_string("./inputs/day14.txt").unwrap();
println!("{}", process_part_2(&file));
}

8
src/bin/day15_1.rs Normal file
View File

@@ -0,0 +1,8 @@
use std::fs;
use aoc2022::day15::process_part_1;
fn main() {
let file = fs::read_to_string("./inputs/day15.txt").unwrap();
println!("{}", process_part_1(&file, 2_000_000));
}

8
src/bin/day15_2.rs Normal file
View File

@@ -0,0 +1,8 @@
use std::fs;
use aoc2022::day15::process_part_2;
fn main() {
let file = fs::read_to_string("./inputs/day15.txt").unwrap();
println!("{}", process_part_2(&file, 4_000_000));
}

8
src/bin/day16_1.rs Normal file
View File

@@ -0,0 +1,8 @@
use std::fs;
use aoc2022::day16::process_part_1;
fn main() {
let file = fs::read_to_string("./inputs/day16.txt").unwrap();
println!("{}", process_part_1(&file));
}

8
src/bin/day16_2.rs Normal file
View File

@@ -0,0 +1,8 @@
use std::fs;
use aoc2022::day16::process_part_2;
fn main() {
let file = fs::read_to_string("./inputs/day16.txt").unwrap();
println!("{}", process_part_2(&file));
}

8
src/bin/day17_1.rs Normal file
View File

@@ -0,0 +1,8 @@
use std::fs;
use aoc2022::day17::process_part_1;
fn main() {
let file = fs::read_to_string("./inputs/day17.txt").unwrap();
println!("{}", process_part_1(&file));
}

8
src/bin/day17_2.rs Normal file
View File

@@ -0,0 +1,8 @@
use std::fs;
use aoc2022::day17::process_part_2;
fn main() {
let file = fs::read_to_string("./inputs/day17.txt").unwrap();
println!("{}", process_part_2(&file));
}

8
src/bin/day18_1.rs Normal file
View File

@@ -0,0 +1,8 @@
use std::fs;
use aoc2022::day18::process_part_1;
fn main() {
let file = fs::read_to_string("./inputs/day18.txt").unwrap();
println!("{}", process_part_1(&file));
}

8
src/bin/day18_2.rs Normal file
View File

@@ -0,0 +1,8 @@
use std::fs;
use aoc2022::day18::process_part_2;
fn main() {
let file = fs::read_to_string("./inputs/day18.txt").unwrap();
println!("{}", process_part_2(&file));
}

8
src/bin/day19_1.rs Normal file
View File

@@ -0,0 +1,8 @@
use std::fs;
use aoc2022::day19::process_part_1;
fn main() {
let file = fs::read_to_string("./inputs/day19.txt").unwrap();
println!("{}", process_part_1(&file));
}

8
src/bin/day19_2.rs Normal file
View File

@@ -0,0 +1,8 @@
use std::fs;
use aoc2022::day19::process_part_2;
fn main() {
let file = fs::read_to_string("./inputs/day19.txt").unwrap();
println!("{}", process_part_2(&file));
}

8
src/bin/day20_1.rs Normal file
View File

@@ -0,0 +1,8 @@
use std::fs;
use aoc2022::day20::process_part_1;
fn main() {
let file = fs::read_to_string("./inputs/day20.txt").unwrap();
println!("{}", process_part_1(&file));
}

8
src/bin/day20_2.rs Normal file
View File

@@ -0,0 +1,8 @@
use std::fs;
use aoc2022::day20::process_part_2;
fn main() {
let file = fs::read_to_string("./inputs/day20.txt").unwrap();
println!("{}", process_part_2(&file));
}

8
src/bin/day21_1.rs Normal file
View File

@@ -0,0 +1,8 @@
use std::fs;
use aoc2022::day21::process_part_1;
fn main() {
let file = fs::read_to_string("./inputs/day21.txt").unwrap();
println!("{}", process_part_1(&file));
}

8
src/bin/day21_2.rs Normal file
View File

@@ -0,0 +1,8 @@
use std::fs;
use aoc2022::day21::process_part_2;
fn main() {
let file = fs::read_to_string("./inputs/day21.txt").unwrap();
println!("{}", process_part_2(&file));
}

8
src/bin/day22_1.rs Normal file
View File

@@ -0,0 +1,8 @@
use std::fs;
use aoc2022::day22::process_part_1;
fn main() {
let file = fs::read_to_string("./inputs/day22.txt").unwrap();
println!("{}", process_part_1(&file));
}

8
src/bin/day22_2.rs Normal file
View File

@@ -0,0 +1,8 @@
use std::fs;
use aoc2022::day22::process_part_2;
fn main() {
let file = fs::read_to_string("./inputs/day22.txt").unwrap();
println!("{}", process_part_2(&file, 50));
}

8
src/bin/day23_1.rs Normal file
View File

@@ -0,0 +1,8 @@
use std::fs;
use aoc2022::day23::process_part_1;
fn main() {
let file = fs::read_to_string("./inputs/day23.txt").unwrap();
println!("{}", process_part_1(&file));
}

8
src/bin/day23_2.rs Normal file
View File

@@ -0,0 +1,8 @@
use std::fs;
use aoc2022::day23::process_part_2;
fn main() {
let file = fs::read_to_string("./inputs/day23.txt").unwrap();
println!("{}", process_part_2(&file));
}

View File

@@ -36,9 +36,7 @@ mod tests {
assert_eq!( assert_eq!(
process_part_1(input), process_part_1(input),
*expected, *expected,
"Expected input {} to return {}", "Expected input {input} to return {expected}"
input,
expected
); );
} }
} }
@@ -49,9 +47,7 @@ mod tests {
assert_eq!( assert_eq!(
process_part_2(input), process_part_2(input),
*expected, *expected,
"Expected input {} to return {}", "Expected input {input} to return {expected}"
input,
expected
); );
} }
} }

118
src/day12.rs Normal file
View File

@@ -0,0 +1,118 @@
use std::collections::{HashSet, VecDeque};
type Coord = (usize, usize);
type Map = Vec<Vec<i8>>;
// ah yes, Breadth First Search
pub fn process_part_1(input: &str) -> u32 {
let (start, target, map) = parse_input(input);
let mut queue = VecDeque::from([(start, map[start.1][start.0], 0)]);
let mut visited = HashSet::from([start]);
while !queue.is_empty() {
let (pos, elevation, steps) = queue.pop_front().unwrap();
if pos == target {
return steps;
}
for (neighbor, neighbor_elevation) in neighbors(&map, pos) {
if neighbor_elevation - elevation <= 1 && !visited.contains(&neighbor) {
queue.push_back((neighbor, neighbor_elevation, steps + 1));
visited.insert(neighbor);
}
}
}
panic!("no path");
}
pub fn process_part_2(input: &str) -> u32 {
let (_, target, map) = parse_input(input);
let mut queue = VecDeque::from([(target, map[target.1][target.0], 0)]);
let mut visited = HashSet::from([target]);
while !queue.is_empty() {
let (pos, elevation, steps) = queue.pop_front().unwrap();
if elevation == 0 {
return steps;
}
for (neighbor, neighbor_elevation) in neighbors(&map, pos) {
if elevation - neighbor_elevation <= 1 && !visited.contains(&neighbor) {
queue.push_back((neighbor, neighbor_elevation, steps + 1));
visited.insert(neighbor);
}
}
}
panic!("no path");
}
pub fn parse_input(input: &str) -> (Coord, Coord, Map) {
let mut start = (0, 0);
let mut end = (0, 0);
let map = input
.lines()
.enumerate()
.map(|(y, line)| {
line.chars()
.enumerate()
.map(|(x, c)| match c {
'S' => {
start = (x, y);
'a'
}
'E' => {
end = (x, y);
'z'
}
_ => c,
})
.map(char_to_int)
.collect()
})
.collect();
(start, end, map)
}
// data only contains a-z, S and E
// this one only deals with a-z
pub fn char_to_int(c: char) -> i8 {
(c as i16 - 'a' as i16) as i8
}
pub fn neighbors(map: &Map, pos: Coord) -> Vec<(Coord, i8)> {
[(-1, 0), (1, 0), (0, -1), (0, 1)]
.into_iter()
.flat_map(|(x, y)| {
// Haha wow, I simultaneously hate and love this
// Reminder to the reader that flat_map flattens Options as much as it can flatten Vec's
Some((
(pos.0.checked_add_signed(x)?),
(pos.1.checked_add_signed(y)?),
))
})
.flat_map(|(x, y)| Some(((x, y), *map.get(y)?.get(x)?)))
.collect()
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &str = "Sabqponm
abcryxxl
accszExk
acctuvwj
abdefghi";
#[test]
fn day1() {
assert_eq!(process_part_1(INPUT), 31);
}
#[test]
fn day2() {
assert_eq!(process_part_2(INPUT), 29);
}
}

138
src/day13.rs Normal file
View File

@@ -0,0 +1,138 @@
use std::cmp::Ordering;
use std::fmt::{Debug, Formatter};
use itertools::Itertools;
use nom::branch::alt;
use nom::bytes::complete::tag;
use nom::character::complete;
use nom::character::complete::newline;
use nom::multi::{many1, separated_list0, separated_list1};
use nom::sequence::delimited;
use nom::{IResult, Parser};
pub fn process_part_1(input: &str) -> usize {
let packets = parse_input(input).unwrap().1;
packets
.iter()
.tuples::<(_, _)>()
.enumerate()
.filter_map(|(i, (a, b))| match a.cmp(b) {
Ordering::Less => Some(i + 1),
Ordering::Equal => panic!("oh no"),
_ => None,
})
.sum()
}
pub fn process_part_2(input: &str) -> usize {
let packets = parse_input(input).unwrap().1;
let div_2 = Packet::List(vec![Packet::List(vec![Packet::Value(2)])]);
let div_6 = Packet::List(vec![Packet::List(vec![Packet::Value(6)])]);
packets
.iter()
.chain([&div_2, &div_6])
.sorted()
.enumerate()
.filter(|&(_i, item)| item == &div_2 || item == &div_6)
.map(|(i, _)| i + 1)
.product()
}
#[derive(Clone)]
enum Packet {
List(Vec<Packet>),
Value(u32),
}
impl Debug for Packet {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Packet::List(v) => write!(f, "{v:?}"),
Packet::Value(v) => write!(f, "{v}"),
}
}
}
impl Eq for Packet {}
impl PartialEq<Self> for Packet {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Packet::Value(a), Packet::Value(b)) => a == b,
(Packet::List(a), Packet::List(b)) => a == b,
(Packet::Value(a), Packet::List(b)) => &vec![Packet::Value(*a)] == b,
(Packet::List(a), Packet::Value(b)) => a == &vec![Packet::Value(*b)],
}
}
}
impl PartialOrd<Self> for Packet {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl Ord for Packet {
fn cmp(&self, other: &Self) -> Ordering {
match (self, other) {
(Packet::Value(a), Packet::Value(b)) => a.cmp(b),
(Packet::List(a), Packet::List(b)) => a.cmp(b),
(Packet::Value(a), Packet::List(b)) => vec![Packet::Value(*a)].cmp(b),
(Packet::List(a), Packet::Value(b)) => a.cmp(&vec![Packet::Value(*b)]),
}
}
}
// I originally parsed tuples but for part 2 I needed the full list without tuples.
// so lets just parse without. We'll just tuple-ify the iterator afterwards.
fn parse_input(input: &str) -> IResult<&str, Vec<Packet>> {
separated_list1(many1(newline), parse_packet)(input)
}
fn parse_packet(input: &str) -> IResult<&str, Packet> {
alt((
complete::u32.map(Packet::Value),
delimited(tag("["), separated_list0(tag(","), parse_packet), tag("]")).map(Packet::List),
))(input)
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &str = "[1,1,3,1,1]
[1,1,5,1,1]
[[1],[2,3,4]]
[[1],4]
[9]
[[8,7,6]]
[[4,4],4,4]
[[4,4],4,4,4]
[7,7,7,7]
[7,7,7]
[]
[3]
[[[]]]
[[]]
[1,[2,[3,[4,[5,6,7]]]],8,9]
[1,[2,[3,[4,[5,6,0]]]],8,9]";
#[test]
fn day1() {
assert_eq!(process_part_1(INPUT), 13);
}
#[test]
fn day2() {
assert_eq!(process_part_2(INPUT), 140);
}
}

189
src/day14.rs Normal file
View File

@@ -0,0 +1,189 @@
use std::collections::HashMap;
use std::fmt::{Display, Formatter};
use itertools::Itertools;
use nom::bytes::complete::tag;
use nom::character::complete;
use nom::character::complete::newline;
use nom::multi::separated_list1;
use nom::sequence::separated_pair;
use nom::IResult;
pub fn process_part_1(input: &str) -> u32 {
let mut map = parse_input(input).unwrap().1;
let mut count = 0;
while map.drop_sand(500, 0, map.max_y).is_some() {
count += 1;
}
count
}
pub fn process_part_2(input: &str) -> u32 {
let mut map = parse_input(input).unwrap().1;
// The final sand actually counts
let mut count = 1;
while map.drop_sand(500, 0, map.max_y + 2) != Some((500, 0)) {
count += 1;
}
count
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
enum Tile {
Air,
Rock,
Sand,
}
impl Display for Tile {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}",
match self {
Tile::Air => " ",
Tile::Rock => "#",
Tile::Sand => "o",
}
)
}
}
#[derive(Debug)]
struct Map {
min_x: u32,
max_x: u32,
min_y: u32,
max_y: u32,
map: HashMap<(u32, u32), Tile>,
}
impl From<HashMap<(u32, u32), Tile>> for Map {
fn from(value: HashMap<(u32, u32), Tile>) -> Self {
let mut map = Map {
min_x: 0,
max_x: 0,
min_y: 0,
max_y: 0,
map: value,
};
map.update_bounds();
map
}
}
impl Map {
fn drop_sand(&mut self, mut x: u32, mut y: u32, max_depth: u32) -> Option<(u32, u32)> {
'falling: for _ in 0..max_depth {
let new_y = y + 1;
for new_x in [x, x - 1, x + 1] {
if self.tile_at(new_x, new_y) == Tile::Air {
x = new_x;
y = new_y;
continue 'falling; // heh
}
}
// We found a place for sand to rest
self.set_tile(x, y, Tile::Sand);
return Some((x, y));
}
// We went max_depth steps, assume we are in the void
None
}
fn set_tile(&mut self, x: u32, y: u32, tile: Tile) {
self.map
.entry((x, y))
.and_modify(|v| {
*v = tile;
})
.or_insert(tile);
}
fn tile_at(&self, x: u32, y: u32) -> Tile {
// For part 2, part 1 won't reach y+2 due to the max steps
if y >= self.max_y + 2 {
Tile::Rock
} else {
self.map.get(&(x, y)).copied().unwrap_or(Tile::Air)
}
}
fn update_bounds(&mut self) {
let mut keys = self.map.keys();
(self.min_x, self.min_y) = *keys.next().unwrap_or(&(0, 0));
(self.max_x, self.max_y) = (self.min_x, self.max_y);
for &(x, y) in keys {
self.min_x = self.min_x.min(x);
self.min_y = self.min_y.min(y);
self.max_x = self.max_x.max(x);
self.max_y = self.max_y.max(y);
}
}
}
impl Display for Map {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
for y in self.min_y..=self.max_y + 2 {
for x in self.min_x..=self.max_x {
write!(f, "{}", self.tile_at(x, y))?;
}
writeln!(f)?;
}
Ok(())
}
}
fn parse_input(input: &str) -> IResult<&str, Map> {
let (input, rocks) = separated_list1(newline, parse_line)(input)?;
Ok((
input,
rocks
.into_iter()
.flatten()
.map(|pos| (pos, Tile::Rock))
.collect::<HashMap<_, _>>()
.into(),
))
}
fn parse_line(input: &str) -> IResult<&str, impl Iterator<Item = (u32, u32)>> {
let (input, pairs) = separated_list1(
tag(" -> "),
separated_pair(complete::u32, complete::char(','), complete::u32),
)(input)?;
Ok((
input,
pairs
.into_iter()
.tuple_windows::<(_, _)>()
.flat_map(|((ax, ay), (bx, by))| {
(ax.min(bx)..=ax.max(bx)).cartesian_product(ay.min(by)..=ay.max(by))
}),
))
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &str = "498,4 -> 498,6 -> 496,6
503,4 -> 502,4 -> 502,9 -> 494,9";
#[test]
fn day1() {
assert_eq!(process_part_1(INPUT), 24);
}
#[test]
fn day2() {
assert_eq!(process_part_2(INPUT), 93);
}
}

126
src/day15.rs Normal file
View File

@@ -0,0 +1,126 @@
use itertools::{Itertools, MinMaxResult};
use nom::bytes::complete::tag;
use nom::character::complete;
use nom::character::complete::newline;
use nom::multi::separated_list1;
use nom::sequence::{preceded, separated_pair};
use nom::IResult;
pub fn process_part_1(input: &str, row: isize) -> usize {
let sensors = parse_input(input).unwrap().1;
let (min_x, max_x) = match sensors
.iter()
.flat_map(|sensor| {
[
sensor.pos.0 + sensor.distance as isize,
sensor.pos.0 - sensor.distance as isize,
]
})
.minmax()
{
MinMaxResult::NoElements => panic!("invalid sensors!"),
MinMaxResult::OneElement(e) => (e, e),
MinMaxResult::MinMax(min, max) => (min, max),
};
(min_x..=max_x)
.filter(|&i| sensors.iter().any(|s| s.is_in_range((i, row))))
.count()
}
pub fn process_part_2(input: &str, max_n: isize) -> isize {
let sensors = parse_input(input).unwrap().1;
sensors
.iter()
.find_map(|sensor| {
// just outside the leftmost side of the sensor
((sensor.pos.0 - (sensor.distance as isize) - 1).max(0)
..=(sensor.pos.0 + (sensor.distance as isize) + 1).min(max_n))
.zip(sensor.pos.1..=max_n)
.find_map(|pos| {
sensors
.iter()
.all(|s| !s.is_in_range(pos))
.then_some(pos.0 * 4_000_000 + pos.1)
})
})
.unwrap()
}
type Pos = (isize, isize);
#[derive(Debug, Copy, Clone)]
struct Sensor {
pos: Pos,
closest_beacon: Pos,
distance: usize,
}
impl Sensor {
fn new(sensor_pos: Pos, beacon_pos: Pos) -> Self {
Self {
pos: sensor_pos,
closest_beacon: beacon_pos,
distance: manhattan(sensor_pos, beacon_pos),
}
}
fn is_in_range(&self, p: Pos) -> bool {
if self.closest_beacon == p {
return false;
}
self.distance >= manhattan(self.pos, p)
}
}
fn parse_input(input: &str) -> IResult<&str, Vec<Sensor>> {
separated_list1(newline, parse_sensor)(input)
}
fn parse_sensor(input: &str) -> IResult<&str, Sensor> {
let (input, sensor_pos) = preceded(tag("Sensor at "), parse_pos)(input)?;
let (input, beacon_pos) = preceded(tag(": closest beacon is at "), parse_pos)(input)?;
Ok((input, Sensor::new(sensor_pos, beacon_pos)))
}
fn parse_pos(input: &str) -> IResult<&str, Pos> {
let (input, (x, y)) = separated_pair(
preceded(tag("x="), complete::i32),
tag(", "),
preceded(tag("y="), complete::i32),
)(input)?;
Ok((input, (x as isize, y as isize)))
}
fn manhattan(a: Pos, b: Pos) -> usize {
a.0.abs_diff(b.0) + a.1.abs_diff(b.1)
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &str = "Sensor at x=2, y=18: closest beacon is at x=-2, y=15
Sensor at x=9, y=16: closest beacon is at x=10, y=16
Sensor at x=13, y=2: closest beacon is at x=15, y=3
Sensor at x=12, y=14: closest beacon is at x=10, y=16
Sensor at x=10, y=20: closest beacon is at x=10, y=16
Sensor at x=14, y=17: closest beacon is at x=10, y=16
Sensor at x=8, y=7: closest beacon is at x=2, y=10
Sensor at x=2, y=0: closest beacon is at x=2, y=10
Sensor at x=0, y=11: closest beacon is at x=2, y=10
Sensor at x=20, y=14: closest beacon is at x=25, y=17
Sensor at x=17, y=20: closest beacon is at x=21, y=22
Sensor at x=16, y=7: closest beacon is at x=15, y=3
Sensor at x=14, y=3: closest beacon is at x=15, y=3
Sensor at x=20, y=1: closest beacon is at x=15, y=3";
#[test]
fn day1() {
assert_eq!(process_part_1(INPUT, 10), 26);
}
#[test]
fn day2() {
assert_eq!(process_part_2(INPUT, 20), 56000011);
}
}

191
src/day16.rs Normal file
View File

@@ -0,0 +1,191 @@
use std::collections::HashMap;
use bitvec::prelude::BitArray;
use itertools::Itertools;
use nom::branch::alt;
use nom::bytes::complete::{tag, take};
use nom::character::complete;
use nom::character::complete::newline;
use nom::multi::separated_list1;
use nom::sequence::preceded;
use nom::IResult;
use petgraph::algo::floyd_warshall;
use petgraph::prelude::{NodeIndex, UnGraph};
use rayon::prelude::*;
pub fn process_part_1(input: &str) -> usize {
let data = parse_input(input).unwrap().1;
let distances = floyd_warshall(&data.graph, |_| 1).unwrap();
let targets = data.targets();
max_released(
&data.graph,
&distances,
data.start,
30,
&targets,
BitArray::ZERO,
)
}
pub fn process_part_2(input: &str) -> usize {
let data = parse_input(input).unwrap().1;
let distances = floyd_warshall(&data.graph, |_| 1).unwrap();
let targets = data.targets();
// Split targets about evenly. Human takes (i) nodes, leaving (|targets| - i) nodes for the elephant
(1..=targets.len() / 2)
.into_par_iter()
.flat_map(|n| targets.iter().copied().combinations(n).collect_vec())
.map(|human_nodes| {
let elephant_nodes = targets
.iter()
.copied()
.filter(|n| !human_nodes.contains(n))
.collect();
let max_human = max_released(
&data.graph,
&distances,
data.start,
26,
&human_nodes,
BitArray::ZERO,
);
let max_elephant = max_released(
&data.graph,
&distances,
data.start,
26,
&elephant_nodes,
BitArray::ZERO,
);
max_human + max_elephant
})
.max()
.unwrap()
}
fn max_released(
graph: &UnGraph<usize, u8>,
distances: &HashMap<(NodeIndex, NodeIndex), i32>,
start: NodeIndex,
remaining_time: usize,
targets: &Vec<NodeIndex>,
opened: BitArray<u64>,
) -> usize {
let mut max = 0;
// If we are out of time, or if we have opened all valves
if remaining_time == 0 || opened.count_ones() == targets.len() {
return 0;
}
for &valve in targets.iter().filter(|&n| !opened[n.index()]) {
let distance = distances[&(start, valve)].unsigned_abs() as usize;
if remaining_time <= distance {
continue;
}
let mut opened = opened;
opened.set(valve.index(), true);
let next_time_remaining = remaining_time.saturating_sub(distance).saturating_sub(1);
let next_released = max_released(
graph,
distances,
valve,
next_time_remaining,
targets,
opened,
);
let flow = *graph.node_weight(valve).unwrap() * next_time_remaining;
if flow + next_released > max {
max = flow + next_released;
}
}
max
}
#[derive(Debug, Clone)]
struct Data {
graph: UnGraph<usize, u8>,
start: NodeIndex,
}
impl Data {
fn targets(&self) -> Vec<NodeIndex> {
self.graph
.node_indices()
.filter(|&n| *self.graph.node_weight(n).unwrap() > 0)
.collect()
}
}
fn parse_input(input: &str) -> IResult<&str, Data> {
let (input, parsed_valves) = separated_list1(newline, parse_line)(input)?;
let mut graph = UnGraph::new_undirected();
let mut valves = HashMap::new();
let mut valves_by_index = HashMap::new();
// generate graph nodes
for valve in &parsed_valves {
let node = graph.add_node(valve.1);
valves.insert(valve.0, node);
valves_by_index.insert(node, valve.0);
}
// generate graph edges
for valve in &parsed_valves {
let valve_node = valves.get(valve.0).unwrap();
for &neighbor in &valve.2 {
let neighbor_node = valves.get(neighbor).unwrap();
graph.add_edge(*valve_node, *neighbor_node, 1);
}
}
let start = *valves.get("AA").unwrap();
Ok((input, Data { graph, start }))
}
fn parse_line(input: &str) -> IResult<&str, (&str, usize, Vec<&str>)> {
let (input, valve_name) = preceded(tag("Valve "), take(2usize))(input)?;
let (input, flow) = preceded(tag(" has flow rate="), complete::u32)(input)?;
let (input, neighbors) = preceded(
alt((
tag("; tunnels lead to valves "),
tag("; tunnel leads to valve "),
)),
separated_list1(tag(", "), take(2usize)),
)(input)?;
Ok((input, (valve_name, flow as usize, neighbors)))
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &str = "Valve AA has flow rate=0; tunnels lead to valves DD, II, BB
Valve BB has flow rate=13; tunnels lead to valves CC, AA
Valve CC has flow rate=2; tunnels lead to valves DD, BB
Valve DD has flow rate=20; tunnels lead to valves CC, AA, EE
Valve EE has flow rate=3; tunnels lead to valves FF, DD
Valve FF has flow rate=0; tunnels lead to valves EE, GG
Valve GG has flow rate=0; tunnels lead to valves FF, HH
Valve HH has flow rate=22; tunnel leads to valve GG
Valve II has flow rate=0; tunnels lead to valves AA, JJ
Valve JJ has flow rate=21; tunnel leads to valve II";
#[test]
fn day1() {
assert_eq!(process_part_1(INPUT), 1651);
}
// This one is ignored for being slow
#[test]
#[ignore]
fn day2() {
assert_eq!(process_part_2(INPUT), 1707);
}
}

224
src/day17.rs Normal file
View File

@@ -0,0 +1,224 @@
use std::collections::HashMap;
use nom::branch::alt;
use nom::character::complete;
use nom::multi::many1;
use nom::{IResult, Parser};
pub fn process_part_1(input: &str) -> usize {
let mut gusts = parse_input(input).unwrap().1.into_iter().cycle();
let mut templates = all_pieces().into_iter().cycle();
// Leftmost bit is kept as a wall in the grid, right is done in the right() of piece
let mut grid = [0b1000_0000_u8; 10_000];
grid[0] = 0b1111_1111;
(0..2022).fold(0, |z, _| {
let mut piece = Piece {
data: templates.next().unwrap(),
z: z + 4,
};
loop {
match gusts.next() {
Some(Gust::Left) => piece.left(&grid),
Some(Gust::Right) => piece.right(&grid),
None => unreachable!(),
}
if !piece.can_move_down(&grid) {
break;
}
piece.down();
}
piece.paste(&mut grid);
z.max(piece.max_z())
})
}
pub fn process_part_2(input: &str) -> usize {
let mut gusts = parse_input(input)
.unwrap()
.1
.into_iter()
.enumerate()
.cycle();
let mut templates = all_pieces().into_iter().enumerate().cycle();
let mut grid = [0b1000_0000_u8; 10_000];
grid[0] = 0b1111_1111;
let mut cache = HashMap::new();
let mut i = 0;
let mut skipped = 0;
let mut z = 0;
let iterations = 1_000_000_000_000usize;
while i < iterations {
let (piece_id, template) = templates.next().unwrap();
let mut piece = Piece {
data: template,
z: z + 4,
};
let mut gust_id;
loop {
let (i, gust) = gusts.next().unwrap();
gust_id = i;
match gust {
Gust::Left => piece.left(&grid),
Gust::Right => piece.right(&grid),
}
if !piece.can_move_down(&grid) {
break;
}
piece.down();
}
piece.paste(&mut grid);
z = z.max(piece.max_z());
if z > 64 && skipped == 0 {
let key = HashKey {
piece_id,
gust_id,
grid: grid[z - 63..=z].try_into().unwrap(),
};
if let Some((previous_z, previous_i)) = cache.insert(key, (z, i)) {
// We got a cache hit! Let's compare the two states to know the period.
let height_diff = z - previous_z;
let iterations_diff = i - previous_i;
// Now we know how many periods (cycles) we can skip without affecting the state/repetition
let skip_repeats = (iterations - i) / iterations_diff;
let skip_iterations = skip_repeats * iterations_diff;
let skip_height = skip_repeats * height_diff;
// We fast-forward our piece counter
i += skip_iterations;
// We record how much height we skipped, which we will add to the final result to get the real value
skipped = skip_height;
}
}
i += 1;
}
z + skipped
}
#[derive(Hash, PartialEq, Eq)]
struct HashKey {
piece_id: usize,
gust_id: usize,
grid: [u8; 64],
}
#[derive(Debug, Copy, Clone)]
enum Gust {
Left,
Right,
}
fn parse_input(input: &str) -> IResult<&str, Vec<Gust>> {
many1(
alt((complete::char('<'), complete::char('>'))).map(|v| match v {
'<' => Gust::Left,
'>' => Gust::Right,
_ => unreachable!(),
}),
)(input)
}
struct Piece {
data: [u8; 4],
z: usize,
}
impl Piece {
fn left(&mut self, grid: &[u8]) {
// Only the rows we occupy are interesting
let grid = &grid[self.z..self.z + 4];
let collision = grid
.iter()
.zip(self.data)
.any(|(grid, piece)| (piece << 1 & grid) > 0);
if collision {
return;
}
for row in &mut self.data {
*row <<= 1;
}
}
fn right(&mut self, grid: &[u8]) {
// Only the rows we occupy are interesting
let grid = &grid[self.z..self.z + 4];
let collision = grid
.iter()
.zip(self.data)
.any(|(grid, piece)| (piece.trailing_ones() as u8 | (piece >> 1 & grid)) > 0);
if collision {
return;
}
for row in &mut self.data {
*row >>= 1;
}
}
fn can_move_down(&self, grid: &[u8]) -> bool {
let grid = &grid[self.z - 1..=self.z];
!grid
.iter()
.zip(self.data)
.any(|(grid, piece)| (piece & grid) > 0)
}
fn down(&mut self) {
self.z -= 1;
}
fn paste(&self, grid: &mut [u8]) {
for (grid, piece) in grid[self.z..self.z + 4].iter_mut().zip(self.data) {
*grid |= piece
}
}
fn height(&self) -> usize {
self.data
.iter()
.take_while(|row| row.count_ones() > 0)
.count()
}
fn max_z(&self) -> usize {
self.z + self.height() - 1
}
}
fn all_pieces() -> [[u8; 4]; 5] {
[
[0b11110, 0b0, 0b0, 0b0],
[0b1000, 0b11100, 0b1000, 0b0],
[0b11100, 0b100, 0b100, 0b0],
[0b10000; 4],
[0b11000, 0b11000, 0b0, 0b0],
]
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &str = ">>><<><>><<<>><>>><<<>>><<<><<<>><>><<>>";
#[test]
fn day1() {
assert_eq!(process_part_1(INPUT), 3068);
}
#[test]
fn day2() {
assert_eq!(process_part_2(INPUT), 1_514_285_714_288);
}
}

102
src/day18.rs Normal file
View File

@@ -0,0 +1,102 @@
use std::collections::HashSet;
use nom::character::complete;
use nom::character::complete::newline;
use nom::combinator::opt;
use nom::multi::fold_many1;
use nom::sequence::{preceded, terminated, tuple};
use nom::IResult;
pub fn sides((x, y, z): (i32, i32, i32)) -> [(i32, i32, i32); 6] {
[
(x + 1, y, z),
(x - 1, y, z),
(x, y + 1, z),
(x, y - 1, z),
(x, y, z + 1),
(x, y, z - 1),
]
}
pub fn process_part_1(input: &str) -> usize {
let drops = parse_input(input).unwrap().1;
drops
.iter()
.flat_map(|&v| sides(v))
.filter(|v| !drops.contains(v))
.count()
}
pub fn process_part_2(input: &str) -> usize {
let drops = parse_input(input).unwrap().1;
// Flood fill Bounding box so we don't go too far out of sanity, its a dumb bounding box though
let max = drops.iter().flat_map(|&(x, y, z)| [x, y, z]).max().unwrap() + 1;
let mut seen = HashSet::new();
let mut stack = vec![(0, 0, 0)];
while let Some(pos) = stack.pop() {
for (x, y, z) in sides(pos) {
if !drops.contains(&(x, y, z))
&& !seen.contains(&(x, y, z))
&& [x, y, z].iter().all(|&i| -1 <= i && i <= max)
{
seen.insert((x, y, z));
stack.push((x, y, z));
}
}
}
drops
.iter()
.flat_map(|&v| sides(v))
.filter(|v| seen.contains(v))
.count()
}
fn parse_input(input: &str) -> IResult<&str, HashSet<(i32, i32, i32)>> {
fold_many1(parse_line, HashSet::new, |mut set, v| {
set.insert(v);
set
})(input)
}
fn parse_line(input: &str) -> IResult<&str, (i32, i32, i32)> {
terminated(
tuple((
complete::i32,
preceded(complete::char(','), complete::i32),
preceded(complete::char(','), complete::i32),
)),
opt(newline),
)(input)
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &str = "2,2,2
1,2,2
3,2,2
2,1,2
2,3,2
2,2,1
2,2,3
2,2,4
2,2,6
1,2,5
3,2,5
2,1,5
2,3,5";
#[test]
fn day1() {
assert_eq!(process_part_1(INPUT), 64);
}
#[test]
fn day2() {
assert_eq!(process_part_2(INPUT), 58);
}
}

219
src/day19.rs Normal file
View File

@@ -0,0 +1,219 @@
use std::collections::HashSet;
use nom::bytes::complete::tag;
use nom::character::complete;
use nom::character::complete::newline;
use nom::combinator::map;
use nom::multi::separated_list1;
use nom::sequence::{delimited, preceded, separated_pair, tuple};
use nom::IResult;
use rayon::prelude::{IndexedParallelIterator, IntoParallelRefIterator, ParallelIterator};
pub fn process_part_1(input: &str) -> usize {
let blueprints = parse_input(input).unwrap().1;
blueprints
.par_iter()
.map(|bp| bp.id * find_best_geodes(bp, 24))
.sum()
}
pub fn process_part_2(input: &str) -> usize {
let blueprints = parse_input(input).unwrap().1;
blueprints
.par_iter()
.take(3)
.map(|bp| find_best_geodes(bp, 32))
.product()
}
#[derive(Debug)]
struct Blueprint {
id: usize,
ore_bot_cost: usize,
clay_bot_cost: usize,
obsidian_bot_cost: (usize, usize),
geode_bot_cost: (usize, usize),
}
impl Blueprint {
fn max_ore_cost(&self) -> usize {
[
self.ore_bot_cost,
self.clay_bot_cost,
self.obsidian_bot_cost.0,
self.geode_bot_cost.0,
]
.into_iter()
.max()
.unwrap()
}
}
#[derive(Default, Copy, Clone, Debug, Hash, Eq, PartialEq)]
struct State {
time: usize,
ore: usize,
clay: usize,
obsidian: usize,
geode: usize,
ore_bots: usize,
clay_bots: usize,
obsidian_bots: usize,
geode_bots: usize,
}
impl State {
fn upper_limit_geodes(&self) -> usize {
// assumes we can create a bot per every minute
let build_geode_cap = (self.time * (self.time + 1)) / 2;
self.geode + build_geode_cap + self.geode_bots * self.time
}
fn tick(&self) -> Self {
State {
ore: self.ore + self.ore_bots,
clay: self.clay + self.clay_bots,
obsidian: self.obsidian + self.obsidian_bots,
geode: self.geode + self.geode_bots,
time: self.time - 1,
..*self
}
}
}
fn find_best_geodes(bp: &Blueprint, time: usize) -> usize {
let mut visited = HashSet::new();
let mut stack = vec![State {
ore_bots: 1,
time,
..Default::default()
}];
let max_ore_cost = bp.max_ore_cost();
let mut max_geodes = 0;
while let Some(state) = stack.pop() {
if state.time == 0 {
max_geodes = max_geodes.max(state.geode);
continue;
}
// Prune states where its immediately obvious we won't beat the maximum
if state.upper_limit_geodes() < max_geodes {
continue;
}
// Best case, we can build a geode bot:
if state.ore >= bp.geode_bot_cost.0 && state.obsidian >= bp.geode_bot_cost.1 {
let next = State {
geode_bots: state.geode_bots + 1,
ore: state.ore - bp.geode_bot_cost.0 + state.ore_bots,
obsidian: state.obsidian - bp.geode_bot_cost.1 + state.obsidian_bots,
..state.tick()
};
if visited.insert(next) {
stack.push(next);
}
}
// Obsidian bots are nice too, unless we have enough
if state.ore >= bp.obsidian_bot_cost.0
&& state.clay >= bp.obsidian_bot_cost.1
&& state.obsidian_bots < bp.geode_bot_cost.1
{
let next = State {
obsidian_bots: state.obsidian_bots + 1,
ore: state.ore - bp.obsidian_bot_cost.0 + state.ore_bots,
clay: state.clay - bp.obsidian_bot_cost.1 + state.clay_bots,
..state.tick()
};
if visited.insert(next) {
stack.push(next);
}
}
// Clay? also prune if we have enough for obsidian bots
if state.ore >= bp.clay_bot_cost && state.clay_bots < bp.obsidian_bot_cost.1 {
let next = State {
clay_bots: state.clay_bots + 1,
ore: state.ore - bp.clay_bot_cost + state.ore_bots,
..state.tick()
};
if visited.insert(next) {
stack.push(next);
}
}
// Ore? But only if we don't make enough to make any new bot per round we want
if state.ore >= bp.ore_bot_cost && state.ore_bots < max_ore_cost {
let next = State {
ore_bots: state.ore_bots + 1,
ore: state.ore - bp.ore_bot_cost + state.ore_bots,
..state.tick()
};
if visited.insert(next) {
stack.push(next);
}
}
// Final option, do nothing
let next = state.tick();
if visited.insert(next) {
stack.push(next);
}
}
max_geodes
}
fn parse_input(input: &str) -> IResult<&str, Vec<Blueprint>> {
separated_list1(newline, parse_blueprint)(input)
}
fn parse_blueprint(input: &str) -> IResult<&str, Blueprint> {
map(
tuple((
preceded(tag("Blueprint "), complete::u64),
preceded(tag(": Each ore robot costs "), complete::u64),
preceded(tag(" ore. Each clay robot costs "), complete::u64),
preceded(
tag(" ore. Each obsidian robot costs "),
separated_pair(complete::u64, tag(" ore and "), complete::u64),
),
delimited(
tag(" clay. Each geode robot costs "),
separated_pair(complete::u64, tag(" ore and "), complete::u64),
tag(" obsidian."),
),
)),
|(id, ore_bot, clay_bot, (ob_ore, ob_clay), (gb_ore, gb_obs))| Blueprint {
id: id as usize,
ore_bot_cost: ore_bot as usize,
clay_bot_cost: clay_bot as usize,
obsidian_bot_cost: (ob_ore as usize, ob_clay as usize),
geode_bot_cost: (gb_ore as usize, gb_obs as usize),
},
)(input)
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &str = "Blueprint 1: Each ore robot costs 4 ore. Each clay robot costs 2 ore. Each obsidian robot costs 3 ore and 14 clay. Each geode robot costs 2 ore and 7 obsidian.
Blueprint 2: Each ore robot costs 2 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 8 clay. Each geode robot costs 3 ore and 12 obsidian.";
#[test]
fn day1() {
assert_eq!(process_part_1(INPUT), 33);
}
// Slow test ahead
#[test]
#[ignore]
fn day2() {
assert_eq!(process_part_2(INPUT), 3472);
}
}

69
src/day20.rs Normal file
View File

@@ -0,0 +1,69 @@
use itertools::Itertools;
use nom::character::complete;
use nom::character::complete::newline;
use nom::multi::separated_list1;
use nom::IResult;
pub fn process_part_1(input: &str) -> i64 {
let values = parse_input(input).unwrap().1;
let mixed = mix(&values, 1);
let zero_pos = mixed.iter().position(|&v| v == 0).unwrap();
[1000, 2000, 3000]
.into_iter()
.map(|pos| mixed[(zero_pos + pos) % mixed.len()])
.sum()
}
pub fn process_part_2(input: &str) -> i64 {
let values = parse_input(input).unwrap().1;
let values = values.into_iter().map(|v| v * 811589153).collect_vec();
let mixed = mix(&values, 10);
let zero_pos = mixed.iter().position(|&v| v == 0).unwrap();
[1000, 2000, 3000]
.into_iter()
.map(|pos| mixed[(zero_pos + pos) % mixed.len()])
.sum()
}
fn mix(values: &[i64], rounds: usize) -> Vec<i64> {
let mut indices = (0..values.len()).collect::<Vec<_>>();
for _ in 0..rounds {
for (i, &v) in values.iter().enumerate() {
let pos = indices.iter().position(|&index| index == i).unwrap();
let removed = indices.remove(pos);
let new_pos = ((pos as i64) + v).rem_euclid(values.len() as i64 - 1) as usize;
indices.insert(new_pos, removed);
}
}
// reconstruct using mixed indices
indices.iter().map(|&i| values[i]).collect()
}
fn parse_input(input: &str) -> IResult<&str, Vec<i64>> {
separated_list1(newline, complete::i64)(input)
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &str = "1
2
-3
3
-2
0
4";
#[test]
fn day1() {
assert_eq!(process_part_1(INPUT), 3);
}
#[test]
fn day2() {
assert_eq!(process_part_2(INPUT), 1623178306);
}
}

128
src/day21.rs Normal file
View File

@@ -0,0 +1,128 @@
use std::collections::HashMap;
use nom::branch::alt;
use nom::bytes::complete::tag;
use nom::character::complete;
use nom::character::complete::{alpha1, newline, one_of, space1};
use nom::combinator::map;
use nom::multi::separated_list1;
use nom::sequence::separated_pair;
use nom::IResult;
use xxcalc::calculator::Calculator;
pub fn process_part_1(input: &str) -> i64 {
let (_, monkeys) = parse_input(input).unwrap();
monkeys["root"].calc(&monkeys)
}
pub fn process_part_2(input: &str) -> i64 {
let (_, monkeys) = parse_input(input).unwrap();
let expr = match monkeys["root"] {
Monkey::Add(a, b) | Monkey::Sub(a, b) | Monkey::Mul(a, b) | Monkey::Div(a, b) => {
format!("{}={}", build_expr(&monkeys, a), build_expr(&monkeys, b))
}
_ => unreachable!(),
};
// Lazy man, i am
xxcalc::linear_solver::LinearSolver
.process(&expr)
.unwrap()
.as_f64()
.unwrap()
.floor() as i64
}
fn build_expr(monkeys: &HashMap<&str, Monkey>, name: &str) -> String {
if name == "humn" {
return "x".to_owned();
}
match monkeys[name] {
Monkey::Number(x) => format!("{x}"),
Monkey::Add(a, b) => format!("({}+{})", build_expr(monkeys, a), build_expr(monkeys, b)),
Monkey::Sub(a, b) => format!("({}-{})", build_expr(monkeys, a), build_expr(monkeys, b)),
Monkey::Mul(a, b) => format!("({}*{})", build_expr(monkeys, a), build_expr(monkeys, b)),
Monkey::Div(a, b) => format!("({}/{})", build_expr(monkeys, a), build_expr(monkeys, b)),
}
}
#[derive(Debug)]
enum Monkey<'a> {
Number(i64),
Add(&'a str, &'a str),
Sub(&'a str, &'a str),
Mul(&'a str, &'a str),
Div(&'a str, &'a str),
}
impl<'a> Monkey<'a> {
fn calc(&self, monkeys: &HashMap<&str, Monkey>) -> i64 {
match *self {
Monkey::Number(i) => i,
Monkey::Add(a, b) => monkeys[a].calc(monkeys) + monkeys[b].calc(monkeys),
Monkey::Sub(a, b) => monkeys[a].calc(monkeys) - monkeys[b].calc(monkeys),
Monkey::Mul(a, b) => monkeys[a].calc(monkeys) * monkeys[b].calc(monkeys),
Monkey::Div(a, b) => monkeys[a].calc(monkeys) / monkeys[b].calc(monkeys),
}
}
}
fn parse_operation_monkey(input: &str) -> IResult<&str, Monkey> {
let (input, lhs) = alpha1(input)?;
let (input, _) = space1(input)?;
let (input, op) = one_of("+-*/")(input)?;
let (input, _) = space1(input)?;
let (input, rhs) = alpha1(input)?;
Ok((
input,
match op {
'+' => Monkey::Add(lhs, rhs),
'-' => Monkey::Sub(lhs, rhs),
'*' => Monkey::Mul(lhs, rhs),
'/' => Monkey::Div(lhs, rhs),
_ => unreachable!(),
},
))
}
fn parse_monkey(input: &str) -> IResult<&str, Monkey> {
alt((map(complete::i64, Monkey::Number), parse_operation_monkey))(input)
}
fn parse_input(input: &str) -> IResult<&str, HashMap<&str, Monkey>> {
let (input, monkeys) =
separated_list1(newline, separated_pair(alpha1, tag(": "), parse_monkey))(input)?;
Ok((input, HashMap::from_iter(monkeys.into_iter())))
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &str = "root: pppw + sjmn
dbpl: 5
cczh: sllz + lgvd
zczc: 2
ptdq: humn - dvpt
dvpt: 3
lfqf: 4
humn: 5
ljgn: 2
sjmn: drzm * dbpl
sllz: 4
pppw: cczh / lfqf
lgvd: ljgn * ptdq
drzm: hmdt - zczc
hmdt: 32";
#[test]
fn day1() {
assert_eq!(process_part_1(INPUT), 152);
}
#[test]
fn day2() {
assert_eq!(process_part_2(INPUT), 301);
}
}

434
src/day22.rs Normal file
View File

@@ -0,0 +1,434 @@
use itertools::Itertools;
use nom::branch::alt;
use nom::bytes::complete::tag;
use nom::character::complete::{digit1, newline, one_of};
use nom::combinator::map;
use nom::multi::{many1, separated_list1};
use nom::sequence::separated_pair;
use nom::IResult;
pub fn process_part_1(input: &str) -> usize {
let (grid, instructions) = parse_input(input).unwrap().1;
let mut player = Player {
x: grid[0]
.iter()
.position(|t| matches!(t, Tile::Free))
.unwrap(),
y: 0,
dir: Dir::R,
};
for i in instructions {
player.walk1(&i, &grid);
}
1000 * (player.y + 1) + (4 * (player.x + 1)) + isize::from(&player.dir) as usize
}
pub fn process_part_2(input: &str, cube_size: usize) -> usize {
let (grid, instructions) = parse_input(input).unwrap().1;
let mut player = Player {
x: grid[0]
.iter()
.position(|t| matches!(t, Tile::Free))
.unwrap(),
y: 0,
dir: Dir::R,
};
for i in instructions {
player.walk2(&i, &grid, cube_size);
}
1000 * (player.y + 1) + (4 * (player.x + 1)) + isize::from(&player.dir) as usize
}
#[derive(Debug)]
struct Player {
x: usize,
y: usize,
dir: Dir,
}
impl Player {
fn walk1(&mut self, instr: &Instruction, grid: &[Vec<Tile>]) {
match instr {
Instruction::Left => {
self.dir = (isize::from(&self.dir) - 1).rem_euclid(4).into();
}
Instruction::Right => {
self.dir = (isize::from(&self.dir) + 1).rem_euclid(4).into();
}
Instruction::Walk(dist) => {
for _ in 0..*dist {
let (next_x, next_y, next_tile) = match &self.dir {
Dir::R => {
let row = &grid[self.y];
let (next_x, next_tile) = row
.iter()
.enumerate()
.cycle()
.skip(self.x + 1)
.find(|(_, t)| !matches!(t, Tile::None))
.unwrap();
(next_x, self.y, next_tile)
}
Dir::D => {
let col = grid.iter().map_while(|row| row.get(self.x));
let (next_y, next_tile) = col
.enumerate()
.cycle()
.skip(self.y + 1)
.find(|(_, t)| !matches!(t, Tile::None))
.unwrap();
(self.x, next_y, next_tile)
}
Dir::L => {
let row = &grid[self.y];
let (next_x, next_tile) = row
.iter()
.enumerate()
.rev()
.cycle()
.skip(row.len() - self.x)
.find(|(_, t)| !matches!(t, Tile::None))
.unwrap();
(next_x, self.y, next_tile)
}
Dir::U => {
let col = grid.iter().map_while(|row| row.get(self.x)).collect_vec();
let (next_y, next_tile) = col
.iter()
.enumerate()
.rev()
.cycle()
.skip(col.len() - self.y)
.find(|(_, t)| !matches!(t, Tile::None))
.unwrap();
(self.x, next_y, *next_tile)
}
};
match next_tile {
Tile::Free => (self.x, self.y) = (next_x, next_y),
Tile::Wall => break,
Tile::None => unreachable!(),
}
}
}
}
}
fn walk2(&mut self, instr: &Instruction, grid: &[Vec<Tile>], size: usize) {
match instr {
Instruction::Left => {
self.dir = (isize::from(&self.dir) - 1).rem_euclid(4).into();
}
Instruction::Right => {
self.dir = (isize::from(&self.dir) + 1).rem_euclid(4).into();
}
Instruction::Walk(dist) => {
for _ in 0..*dist {
let (next_x, next_y, next_dir) = self.next_coord(size);
let next_tile = &grid[next_y][next_x];
match next_tile {
Tile::Free => {
self.x = next_x;
self.y = next_y;
self.dir = next_dir
}
Tile::Wall => break,
Tile::None => unreachable!(),
}
}
}
}
}
fn next_coord(&self, size: usize) -> (usize, usize, Dir) {
let face = get_face(self.x, self.y, size);
let (xl, yl) = global_to_local(self.x, self.y, size);
match face {
1 => match self.dir {
Dir::R => (self.x + 1, self.y, Dir::R),
Dir::L => {
if xl == 0 {
let (nx, ny) = local_to_global(xl, size - yl - 1, 4, size);
(nx, ny, Dir::R)
} else {
(self.x - 1, self.y, Dir::L)
}
}
Dir::U => {
if yl == 0 {
let (nx, ny) = local_to_global(yl, xl, 6, size);
(nx, ny, Dir::R)
} else {
(self.x, self.y - 1, Dir::U)
}
}
Dir::D => (self.x, self.y + 1, Dir::D),
},
2 => match self.dir {
Dir::R => {
if xl == size - 1 {
let (nx, ny) = local_to_global(xl, size - yl - 1, 5, size);
(nx, ny, Dir::L)
} else {
(self.x + 1, self.y, Dir::R)
}
}
Dir::L => (self.x - 1, self.y, Dir::L),
Dir::U => {
if yl == 0 {
let (nx, ny) = local_to_global(xl, size - 1, 6, size);
(nx, ny, Dir::U)
} else {
(self.x, self.y - 1, Dir::U)
}
}
Dir::D => {
if yl == size - 1 {
let (nx, ny) = local_to_global(yl, xl, 3, size);
(nx, ny, Dir::L)
} else {
(self.x, self.y + 1, Dir::D)
}
}
},
3 => match self.dir {
Dir::R => {
if xl == size - 1 {
let (nx, ny) = local_to_global(yl, xl, 2, size);
(nx, ny, Dir::U)
} else {
(self.x + 1, self.y, Dir::R)
}
}
Dir::L => {
if xl == 0 {
let (nx, ny) = local_to_global(yl, xl, 4, size);
(nx, ny, Dir::D)
} else {
(self.x - 1, self.y, Dir::L)
}
}
Dir::U => (self.x, self.y - 1, Dir::U),
Dir::D => (self.x, self.y + 1, Dir::D),
},
4 => match self.dir {
Dir::R => (self.x + 1, self.y, Dir::R),
Dir::L => {
if xl == 0 {
let (nx, ny) = local_to_global(xl, size - yl - 1, 1, size);
(nx, ny, Dir::R)
} else {
(self.x - 1, self.y, Dir::L)
}
}
Dir::U => {
if yl == 0 {
let (nx, ny) = local_to_global(yl, xl, 3, size);
(nx, ny, Dir::R)
} else {
(self.x, self.y - 1, Dir::U)
}
}
Dir::D => (self.x, self.y + 1, Dir::D),
},
5 => match self.dir {
Dir::R => {
if xl == size - 1 {
let (nx, ny) = local_to_global(xl, size - yl - 1, 2, size);
(nx, ny, Dir::L)
} else {
(self.x + 1, self.y, Dir::R)
}
}
Dir::L => (self.x - 1, self.y, Dir::L),
Dir::U => (self.x, self.y - 1, Dir::U),
Dir::D => {
if yl == size - 1 {
let (nx, ny) = local_to_global(yl, xl, 6, size);
(nx, ny, Dir::L)
} else {
(self.x, self.y + 1, Dir::D)
}
}
},
_ => match self.dir {
Dir::R => {
if xl == size - 1 {
let (nx, ny) = local_to_global(yl, xl, 5, size);
(nx, ny, Dir::U)
} else {
(self.x + 1, self.y, Dir::R)
}
}
Dir::L => {
if xl == 0 {
let (nx, ny) = local_to_global(yl, xl, 1, size);
(nx, ny, Dir::D)
} else {
(self.x - 1, self.y, Dir::L)
}
}
Dir::U => (self.x, self.y - 1, Dir::U),
Dir::D => {
if yl == size - 1 {
let (nx, ny) = local_to_global(xl, 0, 2, size);
(nx, ny, Dir::D)
} else {
(self.x, self.y + 1, Dir::D)
}
}
},
}
}
}
// Look, i'm just hardcoding it
// _12
// _3_
// 45_
// 6__
fn get_face(x: usize, y: usize, size: usize) -> usize {
if y < size {
if x < 2 * size {
return 1;
}
return 2;
}
if y < 2 * size {
return 3;
}
if y < 3 * size {
if x < size {
return 4;
}
return 5;
}
6
}
fn global_to_local(x: usize, y: usize, size: usize) -> (usize, usize) {
let face = get_face(x, y, size);
match face {
1 => (x - size, y),
2 => (x - 2 * size, y),
3 => (x - size, y - size),
4 => (x, y - 2 * size),
5 => (x - size, y - 2 * size),
6 => (x, y - 3 * size),
_ => unreachable!(),
}
}
fn local_to_global(x: usize, y: usize, face: usize, size: usize) -> (usize, usize) {
match face {
1 => (x + size, y),
2 => (x + 2 * size, y),
3 => (x + size, y + size),
4 => (x, y + 2 * size),
5 => (x + size, y + 2 * size),
6 => (x, y + 3 * size),
_ => unreachable!(),
}
}
#[derive(Debug)]
pub enum Tile {
None,
Free,
Wall,
}
#[derive(Debug)]
pub enum Instruction {
Walk(usize),
Left,
Right,
}
#[derive(Debug)]
pub enum Dir {
R,
D,
L,
U,
}
impl From<&Dir> for isize {
fn from(value: &Dir) -> Self {
match value {
Dir::R => 0,
Dir::D => 1,
Dir::L => 2,
Dir::U => 3,
}
}
}
impl From<isize> for Dir {
fn from(value: isize) -> Self {
match value {
0 => Dir::R,
1 => Dir::D,
2 => Dir::L,
3 => Dir::U,
_ => panic!("invalid direction"),
}
}
}
fn parse_input(input: &str) -> IResult<&str, (Vec<Vec<Tile>>, Vec<Instruction>)> {
separated_pair(parse_grid, tag("\n\n"), parse_instructions)(input)
}
fn parse_grid(input: &str) -> IResult<&str, Vec<Vec<Tile>>> {
separated_list1(
newline,
many1(map(one_of(" .#"), |c| match c {
' ' => Tile::None,
'.' => Tile::Free,
'#' => Tile::Wall,
_ => unreachable!(),
})),
)(input)
}
fn parse_instructions(input: &str) -> IResult<&str, Vec<Instruction>> {
many1(map(alt((digit1, tag("R"), tag("L"))), |c| match c {
"R" => Instruction::Right,
"L" => Instruction::Left,
dist => Instruction::Walk(dist.parse().unwrap()),
}))(input)
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &str = " ...#
.#..
#...
....
...#.......#
........#...
..#....#....
..........#.
...#....
.....#..
.#......
......#.
10R5L5R10L4R5L5";
#[test]
fn day1() {
assert_eq!(process_part_1(INPUT), 6032);
}
#[test]
fn day2() {
// no test, because the test folding is different than the input folding
// SO FUCK THAT GARBAGE
// assert_eq!(process_part_2(INPUT, 4), 5031);
assert_eq!(0, 0);
}
}

180
src/day23.rs Normal file
View File

@@ -0,0 +1,180 @@
use std::collections::BTreeSet;
use std::fmt::{Display, Formatter};
use derive_more::{Add, Sub};
use itertools::Itertools;
use itertools::MinMaxResult::MinMax;
use nom::character::complete::{newline, one_of};
use nom::multi::{many1, separated_list1};
use nom::IResult;
#[derive(Debug, Clone, Copy, Default, Eq, PartialEq, Ord, PartialOrd, Hash, Add, Sub)]
struct Vec2 {
x: i64,
y: i64,
}
impl Display for Vec2 {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "({}, {})", self.x, self.y)
}
}
impl From<(usize, usize)> for Vec2 {
fn from(value: (usize, usize)) -> Self {
Self {
x: value.0 as i64,
y: value.1 as i64,
}
}
}
// didn't wanna write them myself
macro_rules! vec2 {
($x:expr,$y:expr) => {
Vec2 { x: $x, y: $y }
};
}
const DIRECTIONS: [[Vec2; 3]; 4] = [
[vec2!(-1, -1), vec2!(0, -1), vec2!(1, -1)], // North: NW, N, NE
[vec2!(-1, 1), vec2!(0, 1), vec2!(1, 1)], // South: SW, S, SE
[vec2!(-1, -1), vec2!(-1, 0), vec2!(-1, 1)], // West: NW, W, SW
[vec2!(1, -1), vec2!(1, 0), vec2!(1, 1)], // East: NE, E, SE
];
pub fn process_part_1(input: &str) -> usize {
let mut elves = parse_input(input).unwrap().1;
for i in 0..10 {
elves.step(i);
}
elves.bounding_box_area() - elves.0.len()
}
pub fn process_part_2(input: &str) -> usize {
let mut elves = parse_input(input).unwrap().1;
(0..)
.take_while(|i| elves.step(*i))
.last()
.map(|x| x + 2) // we start counting at 0 while aoc expects 1, and take_while 'noms' the one we need to keep away
.unwrap_or(0)
}
fn parse_input(input: &str) -> IResult<&str, Elves> {
let (input, items) = separated_list1(newline, many1(one_of(".#")))(input)?;
let result = items
.iter()
.enumerate()
.flat_map(|(y, row)| {
row.iter()
.enumerate()
.flat_map(move |(x, &elem)| match elem {
'#' => Some(Vec2::from((x, y))),
_ => None,
})
})
.collect();
Ok((input, Elves(result)))
}
#[derive(Debug)]
struct Elves(BTreeSet<Vec2>);
impl Elves {
fn step(&mut self, dir_counter: usize) -> bool {
let mut desired_moves = Vec::new();
let mut has_moved = false;
for elf in self.0.iter() {
if !self.has_elf_near(*elf) {
continue;
}
for i in 0..4 {
let offsets = DIRECTIONS[(dir_counter + i) % 4];
if !self.has_elf(*elf, &offsets) {
let next = *elf + offsets[1];
desired_moves.push((next, *elf));
break;
}
}
}
let moves = desired_moves
.into_iter()
.sorted_unstable_by(|a, b| a.0.cmp(&b.0))
.dedup_by_with_count(|a, b| a.0 == b.0)
.filter(|(count, _)| *count == 1)
.map(|(_, m)| m);
for (next, elf) in moves {
self.0.remove(&elf);
self.0.insert(next);
has_moved = true;
}
has_moved
}
fn has_elf_near(&self, pos: Vec2) -> bool {
DIRECTIONS
.iter()
.flatten()
.any(|d| self.0.contains(&(pos + *d)))
}
fn has_elf(&self, pos: Vec2, offsets: &[Vec2]) -> bool {
offsets.iter().any(|d| self.0.contains(&(pos + *d)))
}
fn bounding_box(&self) -> (Vec2, Vec2) {
let MinMax(min_x, max_x) = self.0.iter().minmax_by_key(|p| p.x) else {
panic!("no min/max x?");
};
let MinMax(min_y, max_y) = self.0.iter().minmax_by_key(|p| p.y) else {
panic!("no min/max y?");
};
(vec2!(min_x.x, min_y.y), vec2!(max_x.x, max_y.y))
}
fn bounding_box_area(&self) -> usize {
let (min, max) = self.bounding_box();
((max.x - min.x + 1) * (max.y - min.y + 1)) as usize
}
}
impl Display for Elves {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
let (min, max) = self.bounding_box();
for y in min.y..=max.y {
for x in min.x..=max.x {
let elf = if self.0.contains(&vec2!(x, y)) {
'#'
} else {
'.'
};
write!(f, "{elf}")?;
}
writeln!(f)?;
}
Ok(())
}
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &str = "....#..
..###.#
#...#.#
.#...##
#.###..
##.#.##
.#..#..";
#[test]
fn day1() {
assert_eq!(process_part_1(INPUT), 110);
}
#[test]
fn day2() {
assert_eq!(process_part_2(INPUT), 20);
}
}

View File

@@ -1,9 +1,9 @@
pub fn process_part_1(input: &str) -> u32 { pub fn process_part_1(_input: &str) -> u32 {
return 0; 0
} }
pub fn process_part_2(input: &str) -> u32 { pub fn process_part_2(_input: &str) -> u32 {
return 0; 0
} }
#[cfg(test)] #[cfg(test)]

24
src/day25.rs Normal file
View File

@@ -0,0 +1,24 @@
pub fn process_part_1(_input: &str) -> u32 {
0
}
pub fn process_part_2(_input: &str) -> u32 {
0
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &str = "";
#[test]
fn day1() {
assert_eq!(process_part_1(INPUT), 0);
}
#[test]
fn day2() {
assert_eq!(process_part_2(INPUT), 0);
}
}

View File

@@ -12,3 +12,17 @@ pub mod day08;
pub mod day09; pub mod day09;
pub mod day10; pub mod day10;
pub mod day11; pub mod day11;
pub mod day12;
pub mod day13;
pub mod day14;
pub mod day15;
pub mod day16;
pub mod day17;
pub mod day18;
pub mod day19;
pub mod day20;
pub mod day21;
pub mod day22;
pub mod day23;
pub mod day24;
pub mod day25;