Compare commits

..

35 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
7993a0896b day 11 2022-12-11 22:34:12 +01:00
242b284a59 Blindly follow all clippy's decrees 2022-12-10 12:47:30 +01:00
fd764a46f1 day 10 2022-12-10 12:39:51 +01:00
c8ea1f9fa2 day 9 2022-12-09 19:09:51 +01:00
5b96ff7baf rename input files 2022-12-08 17:09:58 +01:00
5cc16c087d day 8
note: I don't really like this solution but whatever fuck it burn
:flame:
2022-12-08 17:01:10 +01:00
3bb12b8b15 refactor day 7 to be more iterator-y 2022-12-08 01:03:28 +01:00
34f39613f8 fix file reference in day1_2 2022-12-07 20:20:18 +01:00
30edbeb9b9 day 7 2022-12-07 16:12:30 +01:00
67fc0bbcb5 drop the itertools again 2022-12-07 11:01:46 +01:00
5e4e024fcb day 6 2022-12-06 09:11:07 +01:00
bdd3a1c440 reformat day5 test input 2022-12-05 20:22:24 +01:00
55655442a1 day 5 2022-12-05 20:21:06 +01:00
96053f5345 dumb readme 2022-12-04 14:53:04 +01:00
a1c99e8268 day 4 2022-12-04 14:51:24 +01:00
726f75d327 a little bit of scaffolding 2022-12-04 14:16:29 +01:00
510438a247 abuse a nighly feature instead of a dependency 2022-12-04 14:12:09 +01:00
f51e96b5d0 day 3 2022-12-03 14:28:24 +01:00
99 changed files with 19883 additions and 9 deletions

395
Cargo.lock generated
View File

@@ -5,3 +5,398 @@ version = 3
[[package]] [[package]]
name = "aoc2022" name = "aoc2022"
version = "0.1.0" version = "0.1.0"
dependencies = [
"bitvec",
"derive_more",
"itertools",
"nom",
"num",
"petgraph",
"rayon",
"xxcalc",
]
[[package]]
name = "autocfg"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
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]]
name = "either"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
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]]
name = "itertools"
version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
dependencies = [
"either",
]
[[package]]
name = "libc"
version = "0.2.138"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8"
[[package]]
name = "memchr"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
[[package]]
name = "memoffset"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4"
dependencies = [
"autocfg",
]
[[package]]
name = "minimal-lexical"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "nom"
version = "7.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36"
dependencies = [
"memchr",
"minimal-lexical",
]
[[package]]
name = "num"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43db66d1170d347f9a065114077f7dccb00c1b9478c89384490a3425279a4606"
dependencies = [
"num-bigint",
"num-complex",
"num-integer",
"num-iter",
"num-rational",
"num-traits",
]
[[package]]
name = "num-bigint"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
]
[[package]]
name = "num-complex"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ae39348c8bc5fbd7f40c727a9925f03517afd2ab27d46702108b6a7e5414c19"
dependencies = [
"num-traits",
]
[[package]]
name = "num-integer"
version = "0.1.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"
dependencies = [
"autocfg",
"num-traits",
]
[[package]]
name = "num-iter"
version = "0.1.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
]
[[package]]
name = "num-rational"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0"
dependencies = [
"autocfg",
"num-bigint",
"num-integer",
"num-traits",
]
[[package]]
name = "num-traits"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
dependencies = [
"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,3 +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"
nom = "7.1.1"
num = "0.4.0"
petgraph = "0.6.2"
rayon = "1.6.1"
xxcalc = "0.2.1"

1
README.md Normal file
View File

@@ -0,0 +1 @@
# AoC2022

300
inputs/day03.txt Normal file
View File

@@ -0,0 +1,300 @@
BzRmmzZHzVBzgVQmZLPtqqffPqWqJmPLlL
hpvvTDcrCjhpcrvcGGhfLHMlLtMCqflNlWPJlJ
hGjhncHhGnhbTHczBBZVVSbRwgSgRV
rWVQjPQQjGRWNSrWrPjcptwBpqqJBtJBBcZgMdtq
zzmmpzfTCFpTlMlJJwBgMlqMBt
TvLszpbhhTLmsnRQPDQGWDWRvQSR
zGzvLlGlQHLGBQZlhBWhdjRdmdWRcjPj
fTJNfTfNSRWPhjdjfj
pbsbVVnpSnbVTprnbqqrzvLLgQlGLPLHll
ZCCCsWvNvmsCsCmZLZmgMLRpQMhwQRpQRfphfprpTfpM
tlncPjzlndctbzcPPBcjwDphwrfGGDffbDRpDTGG
cdqnddwzqjNVWVLZZLZq
DTLbDbRrlQbwhhNrmmfwdt
zzMJMzjCjJJjvLjMPJpcgPpzfhHdfqWcqddwtwfqdttcNtdN
pJCzVpCvDZBLsVRQ
STzBBbJzRRBZBRTqCCsfZLtNNLClCsfh
jsQnnQjjHcvQFrcPwCmtLCNlvDfftfff
sGFscMQQMMpqzqbMbd
QlNDWGsjQjgQllWQsbtzqTJczTJcbFmmFJJP
MhLrhgLVndRmzJFzVqqJqP
pSLnMdwhwdRZRSwhLZwLhdGWQjlsgWjNQWWSvgBsWDlj
THjSRFSddTjdBTcPLcVVvVBw
GzWnWfndWfznDfsnsBsPVwVwPPLL
zNflzJWqqzQDdSStHNZNpFFtbj
FSzDmsFSFlDlBzqVjqHHjHHpVgHLbp
rTrTtTQQntRQnQJQgggHZttVgHLBLhZL
WTJJRRQCRRJTRdBCRdvRNDFSWFMPmDlPPSsNPSzS
WQldlMtMVQgVMQHnDGbHGGnRnQmD
rqcZPrCFjmHlbGjZ
zSScchqwchBzTzFzhhSlcCwNtdVWWJgsVdMtWNgNVWTJTd
lMZqjMWllrTTspjprWWSSwgWNSVNDmWGVwFwgN
cdCCdLHcnndHJnmCRntLBnRzDvFNtNDVzgSgwDgFNVzFVv
BRLcCCJCmJdcRhfjPPZphrlrPqlZ
GdGqcrrZGDrvDJJqJHcBvmFFgmFMMgMgBtMLTssLmF
NbPVPDlljPmTmsTj
VfQDhflCCRWdcrQwJvvnJv
RLcWgLCqqPQLcqZwzHgwmmrmmtgwTw
DhbhNrMpnJSDJwVTHmmTVnTTVj
lrsvblMDlcWcfQPQ
PVldlphHwGwJJGdjZZWsRbbsGsNWrWQbNbQR
SqcDvTmDLtfmSmtqppfqzTgTQBrRQsbCFWbNNFQFBBrRbLNb
MgtmTgtfpqVlnVddZMwV
BdmfmPBPSbSNdGSdvWrwcZrccZPPcZnH
jzzLsjsMRlQQVHwswvvZrCHrrT
VqhzVFzplFlpLwpMphLRQQVRmSqgbdGtNJBmNSmgGbtggSgt
DHVpNZjdZjFZWVFHpvFvzmlRzPnlfznFRz
lrTBTsBwwMbrrwLPPfwGmGzvRf
scrtMhMCtJBBBclbHdHttWZWDSqDSjHj
wzqsPmqsbsfqBwPMNRMMZcZmFFNtZM
CgCnhlvvLJgcRFNNBdCpWM
QnQrVgHSvVHjbjTGBbbTHb
HdrVrdqFDdZVmHgRmDRFHMnTdTssMGnLnPJLbPTbCs
SczlScjwcNzplNzQSSfjwQSrTGGsbTsnTCnGTMCMLMGGbN
wQlfjrhfhQFHqZhRZRtD
RsfJDGJvzPNcjpddSWJWMd
LLCbBCwCrCmVVnrmhQFmbVhdcdlWpjZzSpMdWSpcWczSBj
rrLCbTwnHTvzvNGT
wPhPhbCqqSCrtJDlqvlrJr
RVVZddLFRZZcQLvJJtzptlgPJp
TVQRZGVncFdTGWZdCNShHhfPNwwsWPwb
dzLVzPSgrgDDDCMSMLLPwFmdTTcsvmwNwjNsHcFF
nWBGntQfGNGBflWBBqlpRQGbWFvjwsbsFswbvTHjjbmHTc
tBNJBnGBflQnDPJrPhDgrPVg
VtWztWtqpqzWpWzqjNRjNpWTmrrmrSbnmJwSJwnMPrCSJVwM
sDHsBDhBdsBZGcHvLHDLhhCSnRSwCJMZrPbmnMbJSCSR
ccLRhgsLBdRsdHNTFFNNgqTglqzF
hztlmDhPhgPlPNNgmZMCbmwwQjcwjjwMjVCd
RSJRrRqnqQJFqvnTGrHCcHHCCHHbHHMcMvdM
qGJsnQTRsStsftPlhPNl
BFFBLPRCwsLwhlPlRmhcGGrbmmGjfNTTnp
VJMVpzgqggJnrjmjNcMjmT
VqdSZtQgZvtdzqHqHtVZdVQpCDWWFdwlRPDpWPPBCswlWD
fCWCsjPzcbzwRSzVTzhhDLqvdg
TmJtrNJrBLSLJqgS
ptNTQFHrZlnpFPwsWMbRjCpcjR
nJmQNCmbmlllmbClbfMLjMFqbGBsdLFq
ZcgTWcTnMqqMTBqF
tPgctSnPctZZgDWzZgQHwNmHlhlmzlQhlJlw
ZpTCwpffdslvgShCBhqhRz
FDMPnNFNmBPzvRPRBg
nNgMrnnDGjDmJMmnFdZTTsdsrZrslcwcQr
pTmczpCldcdDDnPttpvWSqbpJf
jgjRZMGHhGLgQrjvPWzPJgJvzStbbq
LGNLLNBBzcDFCBwwFC
nJTTqnrNvTzNMzzNfqrTPrJnwpwPpZpsHccZVsBRpcVHwpcp
bgDhgbghLWmFmStctVpZtBCVCCpfZp
LLSgLGSjggFGbSSbmMnrvqvzjfzTNrJrqM
RRpDmmPMTjwfGmJQgQ
WsNscdnvvdVZFVnnrZbjjflwljlbzfGFjQjq
NnLZsNnrrVVVcvdBLTPCPCRMwhPMBMPhCt
lbVvzngGJnVbJHpHtHNPpdSQvc
TsMBswFZsWMWBZMNwPtNNtRNHcNpSQ
CcZCTrZDsjZTsTsshWhrWrTnfgbLDfJzVVLVVlgfnzfVGV
JzTTRtJRZWmWjrMHCT
DDFGlLGcGlSSSLsFGBspPBmNMBHMghmWNmWjWCmWtH
nSSpnbsGlLDnpPsSSspFtVvffRQdVzqvvbqdfVQwRz
sMhzszlHHDsWbthHDqsbJjpLNtmjVJmVLLVLVLBp
nrTPrGwfPLdprzJzdL
wgPQcTGGzgccwCgnRwgRChFhlWSDqWWQMWhssSsMQl
NSNmwtpSpCpvMphCsr
PHcRGPLJMrsvzsqG
QHjbnRMcfbPbQZmlZgZlgBBQ
cPRPbhQjbQRdtPQdLqLHqzFZjCFCqLjC
mmfsnnwrfvwrfSNZFzHHLDCFNlLlqDlN
wsmrwswwGTffMrBnmQttJtcMZQQtPJPbZc
MvBPDDRRdnnvHPCHZLHZsFLL
rmJcbVqbcjWwWjQHLzTZFTHSzFrpsz
cmwllVqqGJbVVVmmqbQcmgRnRvGhGfgDRDZBBBvRdd
nMvMhMnvhnbTZWSSZgHmGJDFmmNDzBmbNmdGBN
rCsPLRCssRjrLLsrLlwRVrcNJQfDQfdBmmfNBGJNzmDPfB
CRjCpLltgtJgJJWq
jshCzJpjzTPpmCWvSlpfwHfSWglf
LQMMNMnHtDtLVRvwwgRWlldgWD
qHVrQNHVMFQtrrBBQMBcrrZsZbzCZhbbJZJsmmsmFPTC
JZQZnsQNMqTngZqJBVfBfPPVBNrwvfPw
SSmDstFjpDpCszDjcLLhrPVlGlrGGVBwrvwVPt
FSssFcLjFjbmFFCzjLcFLRDnMJnTHRnZZTdWqZZWnMnRnZ
GbHRHpldwGMpWhHpCMBlCbRdVSLhnqJLSrDPLPPLPDqVDrhh
gvjWWQvgZFtQFFNqLnVnDnSJzzztDD
ZccccfTsffHdWWdRWwsw
ClCtbHMlnnPPlszV
gSDWSLgWQWQJJNWqgtQjPsnfcdVcLVdVdzfzVzff
WQgqtFQgDgQSFqJhqhSJvNDRrZMZHwHMCbZhTpZbGHMTMG
pZJZlCQtHFhPfdNfCh
zcmLSVczwcMcLDNFHdLPhPWH
szvVVnBmnTGQtHTQ
RVVCNDlNGzlGZqHGHWqWhGqQwH
ZFLFTmpLvvmSqsbb
TrfpBfJpJMlnnNfNZD
qHHlDClHhltMqQsHDhHslGznwdTnzzwDGSdfnwGnwG
mZRNcNcLLPNPBFFbbPmLmbZFSCVfJJTVndVfSwnRzznfTwCS
CcCWFbbBLCWtgWgHjghqvv
TjbzlnlFmfqCFFVVCRWr
PhMcLpPDtMLpwPDvLPJbMhSgVCGqggVqQgCqCgCgSWvv
btbZbNZhJDJJhDtwtsTTTmBzzBBmlNlmHj
FqhjWtqlqmmsnFPTCvMCQMTTCjQd
pfffRfLpgrgGgzrNVzzpGVzRCdMCPJbwwcVMbQPCJVMVdbww
DGGDZRGrHggzSsFQnnWShmtH
vtHVVMMrvVMVrSHvLgvlHcZFCnRCZcccZtRRZfJFCJ
rdDjGsdTQDcNZfdncCRR
rBDsTwBbjbmbbQswswPhqVmmSvpVhlvvqMhHhh
vGBLrqMNvqSLBvvrNbllLHfwStWWtFttccjtRtjtcj
MhCDJmhMDzmcRRcjzWfztH
ZQDmDhVVCQbBVdVNMvvv
ptCtCzhWPWptnhVzzpGZbZTjTjVjFGjVFgVl
fQswRRffmRqZlgrqqFjjSgGg
HwsQDNNsDsmRLLHmffsfvHptBnhtzCvhWpZWBdhnMdCh
RlHzzTqczBPfbnvcpB
wVtNwpSZstppwwMsZhsdnLvnbtBBmbnLFFdnmF
WNQJMVWsZWwGJWhhSNrQzlgHrDCgQRHpCHrl
RrZWpJZRrZpdTGstlchLGGlLMd
NqjDPCQPnQCSvtMzSLhhjM
nQVQDDDDfwBwNCVCNVFNpWpgJgrRTmLTmTmgRTWF
SHMcrMHpcjGcjSrMMbvSvvSvwFTLJwJNtFGFWJNtDLFTLfWN
zqRnPfzQCRzqsmRPzznhszzLtLwQwwFTgWWLDLgWFTwTNQ
qVPZmRZhsCZPhZlRCqRRRCbfpccMBjvMVjdHjjMjSvdf
VVQdHwBZLVltlddtBczhrzvGcWWFRwgsFG
TDTTTqqTSSqjqnmTmPqPPmTmGhRszvsrzsjRsccgzrRzgWGF
DpJPqpWqHbZpllpt
cCSCFsnnZFnscDtNdJFJtJtdmb
VgBqBsqRrHtNdzmNrt
BGLLVVjRBsqPBfsGwPsMfSSZCSfTZTZQpSphfS
plCHCHlgglHHGpNbtngNrDvBDpfQDBQfZDfWZVrr
mTmMLhRfwhsLPQvQZDMZQBQWMB
cwsssmqRTFFfFgtbCtGl
LQPPrCPnMZwqtRMn
cWTSlJWlcplJdDTdGdpDlGcGgqmtwwZtqRrNRRmRdNZqmgNq
GSJcJSjsjTpsvWGWBHLLvVVBBBrFrzVz
NVPCSPMNDSNFVSWCsJJJmpGmZZGLLcpZLHGGtsHt
fwzlBBqghqvzqqlDrHbpHjZHmGZbLZrHLb
dnBgnDqQvwRnSnnFMFMP
BCbPsFFwCRHmDSBmWnvDDj
phhZVzdpVfQZphhZpRhSVnjmrcvvnrWtDrvWDS
TfQJMfLphMhJdfdzpQJRTPbwHHNlgbGwsTGgCP
ttWLlnnvnNnBBtlTqWlpvpndQdZsQQFssFDdsRFdVdRNFQ
jSgrScrbGZSGrrCGsFVMssFsPPFcDDMV
bzSmJbfCZCbzLwllflwqtvvw
zmFTJwFLPmzLztmjDzTJwfNrdFNrFppBSNRGNGdbrpBR
gqlhWQgsZMsvqMlMMvsvqsNlLbcdppbrRpdbbcSrrbbr
vssCgVgCsggZQZCgsnsqWgWvfJPDLwffwTPPmzTnjTPmPmwJ
SpcRTPQLBLWpNNzjmmwwwRrR
tGlfvGhfnbDlbqlChnfFMrwsmwNssTMHMHjFwv
ZlhtCtffCdWcZWZVVT
jTTCcWHWJNgCGTzTmnzrmnGn
BwRRbFvtvvQmJJFMpMJr
ZBBwLvqbBZsRsbVsZSqbcZdJjHHjhfPCJfJfHhgc
VrnDSvvrLrfTdTLGfdRp
zcJzmcFcHGfdGmWTVd
tHsMhwPVctccHFHFcbSDbbPjnNbBnbvBQB
QttWQwLTnLnWTtnffnLQSBFVjNvBjBFNgMdCsVWsjv
pDqcmmRPHqgVBddjvN
DcclzbcbPbJLnNTfnw
plRcpsZDGlGZvWvMCNcLtttq
SrfrwSjSVrSjwbmSrHzmHJCQQPQzqttNNQJMzJtqMW
wSHVnfHfWwwHWFVfSnfgmmRsslFZZDBBGZsZsDTdGRTp
qSFQSgQNgQBrBHHcrW
VTmjVJLTwlTmwTVmsMJMVlJmPvcbvvbCBbGBPjGvBbBGWcbb
DnJTZwmnZRhnpqNdWt
dTVHjZLLZDVCfVHtLDDjQbscjWbSJMJPjsbWWb
FnqrnmzzFllmsWwtsFtQMMFc
lmqzzzngGmlNNBqGllzlBNRvptHHpTCHpDLpgDZdgvHvDD
sdRZQbCfZTSTdlfTZCffccWPHPPcPPwLwctRnLWn
BBJDzFVgCDrCJrqDJJhqJVVMLPHwcctFwcWHHGLcwGwGHnWc
ghpJgqqjCZbQdZpd
tbcpzbHSszcHBgqHGZgJJJhhww
jfvdvRTffQQrrFCRFTnGwJRqNRZVpJGZLZggLh
nQTjTnMndlTdQFMvnrClCnpzmzDtbbmBbcPSzzlmmtzP
BqBqTCSTcqHsJHHM
WWPGVPLtzVgWtjWPGzVjzVGcbDhPsRbDcsbJwNRswRDRss
VQfWjfLFGWLjdFfVzTZZpJTpnmlTrSQlBl
jLNsZjqSHCsGdsmpsm
MvnVFzWMwMVWzfnVDwfBMfnnrCtdtPmPlRrdrJCJrtPDrrPD
zznfFWwMfMfFMwVTMQFnQjhjgjSZhCNbLSTcHHgbbC
GGtssttVmvnnGNMQrrVzgwVrCWMz
FdhfhhcCDhHLfzclZMcrwcQMZM
HHqqCBhHSSpdmjGqmGjtjtjj
bbQLtGMQQtQRQtrDtGprrrbCqwplZhhqSqmdwvdzqqqhSmpS
FsJjJBfnsJcFcFfjVPjWBzldqhqnlZZZzzhmnSvSnm
JPcFfFWjFHJVVsVjPVscsDlLNRHGDbLRMRCDNrCGbG
JdMdlMRJnTwdvcjv
CDLHbNSzzLFgHvnTjrswBNBTNT
QgbvzSFQmZQPQQRW
NTBrNzrpjjjCwGbB
FRbQlcvFvcRQQlRsMlRRRZjwCqMwjmjwJZdLJmjCZC
cVPPQcvlWDNhrbPz
VdbVtbbZJdtJVVdDVZmTLqqTSQvNLjjDShhvSG
zplpnBnFpnrrlghGNpLNqHvqvjNj
cWncllnlPFWzcMwtWWtsVLVRmJWCds
ShLSTnZnTSttTSbLQdfSZTMwcDHwwcHnJvDHnlnlclMM
NmPMsssRrVwjDclHJwwR
gNNMWGzNmqGdtfZTbGGb
sWNNlRHnmJtmntJt
brbbBTbbFbCbqqGgBTrCfmQVVZfSSQQSVtJZSrVZ
bbFqvbDvvGGLGbCCtBGDLbLlcPNHhhccPNcdPPchlsdR
DCFvDvnCnNfMBmMMslDZML
SQQQJHwpSgJSJHQWSWHqJWWbmcBBBLLTsmhhTcZbMhmlshcb
RJRgpJHssgwSQHRqsQPGGjjtNCrrFvvnFjjPrP
mThmsgjzTPjMpcvtWP
GNNBVqVGNZbbNbNqqZQVNVNbWcpdtMCcpCtMWCdCPpQccmpp
VSmNrmmbBfZVlsrssrLTRhRhTn
TdmCvLDCpTRNTdFbbWnnSWCfhjbbzn
GrrMsPVGcQHBGMbhjjSgWfHHDbjb
BPBVqqrQPsQqwrrmmmJdRLDDqFRplT
fpDDJljDlCfDTjprjrfbddWthCSCtdPPQFhSSSWW
HsLZgMGbgBBsNzMvGbdVtVQzFRQSthhFPdtP
sMBmGBmbNvLHGMnrDppTcJmcjpqljf
ptSpSJQqpbNGGDDhcMWrlNHcZZWWls
zRLRRRjvvgjHMMsMpWpc
vmCPLCgwvwdnCzmvLbpTbVQqJJPbJPpTVq
TJCfhhJVFffrJJQQllNWcvWhwvWD
GPSGjjpLslBbpLpLqqqPDvdwvwvNzQWGzDDNdzGN
msbRjbpPqsRpHnlZrmJlnVHT
GGfFsCCTvGDsfTTrhsCMMzptZJMdpdgtrpdMcV
LBlwBHPSqjwwlVggHpnMZcVHMt
ZlZZlBbRPGGTGfmRsD
CtCjbVvzQQZTWVdd
MlSqWlmsmGBSHJHTDFHZ
pcqsmsplwsqclwRtRWgtRnPPvb
zCrzCrsdjrhGDCFqGDjRRPtpWfQQcpfQZcCZPp
VSVwVMgLHHLTwMDTMMVnbWPRZQRcRQPptWnpbZcb
MNBBBlSMvLVwTlVTFdNdhNhFsqsGDrzm
rBLWTwTThWwVVDTwHBsZZWppvpGtpptppmRvFFFMFMfL
qPPNCCbqcbcNqbqQjjJQqzjRpptmlpMGmMlJtftmtFHpMt
QnCgzzQbbQqPcPQnncbdQdnVTwDssZgrShBTVgZZsBSDHT
PFGJFqnfqmPgFJQPWdbLdpDRhbphWjDm
rclNHvcrzCNwrWRprjdMMMph
wsZHwZNvRRQsQqBV
LqlGCPlPLTCPqqQlpqLlWfBfWgcHNRJRfWNsncGH
VVtdwVtDDdVmhrdwSBmjbdzNHgfgJnNnsSnHsNffHgRsgR
wVzhbjmDbDrwjdbztFDDthMCvqPppZQBQLZQTqTvFTvZ
BnQnQFwRmRwmwdBSFDFnmSDVLCJTCTppVVmGLVTCLcgVpC
ZlWvhvZjNrbNvqjNhlfPfqjCGHrsspggTpVLpsJCpcJVgg
vPzNvqjWhqFzGSnRGMDG
wZnMZzzZZchDRtVsqtCtwV
WmWpWWmPPWrmrmBmWrTlTFPNVqVCRSDCQHcqVTtTqsSDSTSD
PrppdFlWWlfrWmpWFffrdcGjJJGggnnhZGdLLgGGndvz
FShHNmNhRhNJmBnQBQJrmP
VTgzDTjwfffwzDvwlcczzVSJbQlBQSWBWCnPJPbJWWbC
tzSVtzvSvGSRZqqFMNtpRR
hPZhGDZpnCGtDhznjmLmdJffdNzJ
glwsSrQwBvLdgLzdcj
QsRbHllzzlHwHlBszWlTBFbpDPMhbPDVGpGFpPtFPp
SRjStRDctgDSBzLvPvNrDhmPLr
QqTHGTPJmmHmhNmH
TGQZsTqFnQZCJTPsnJnZQMjVRBVtcVRSVRBlwccSCtBS
bbsNsvsvnNPTRRllbblLqhtQCqQSLCGGHSqHNC
wFpzFgqVzqVJWFDwqJDmSBBmHBHhShLQhCGSBCGH
MJVpFMqgwMqRRbZsMbZMrP
PPdDhvNDQdmgQPZmQVHHtHGGWVGbffWGvs
MMLCTRRLlLclTLRMRLCwMLHWVctbVVHWWWFfVjVGsFWW
MRSMMlpTJRqClBCRqBDnzqgQPnqgznZPZqbP
MrMNPNNpjvdprWtrpMsthqBfqlnfqcGhVBqFRcnqFG
QbDgSSQbgSDDmDVmlqSCRllRcFqnqfBl
QVJbVmwwDQbzVTgbppNJNMWNjNNPrdpM
WwJJNbtHfpLpVgZZPVFhZh
vmmqlDvRvRfqBSrlzmmMjRBhcVhQVZhVghCQQQQTcTrPTP
jSqMmqRzMDDjvqlBqsBMBmmwGNJwJnwLNfbGwddswnJtJH
RLgRmRggbvbzzPmmRNmzsQWFtSGNtwSNQnntFwnnCw
pDBrBHpHhlldphHBHhJVFSLnWWFJttCtQSttSS
hfHrpphHBppfTvmzgMmbLbgf

1000
inputs/day04.txt Normal file

File diff suppressed because it is too large Load Diff

513
inputs/day05.txt Normal file
View File

@@ -0,0 +1,513 @@
[M] [V] [L]
[G] [V] [C] [G] [D]
[J] [Q] [W] [Z] [C] [J]
[W] [W] [G] [V] [D] [G] [C]
[R] [G] [N] [B] [D] [C] [M] [W]
[F] [M] [H] [C] [S] [T] [N] [N] [N]
[T] [W] [N] [R] [F] [R] [B] [J] [P]
[Z] [G] [J] [J] [W] [S] [H] [S] [G]
1 2 3 4 5 6 7 8 9
move 1 from 5 to 2
move 7 from 7 to 1
move 1 from 1 to 7
move 1 from 4 to 1
move 7 from 9 to 1
move 1 from 3 to 7
move 4 from 5 to 4
move 6 from 4 to 9
move 2 from 7 to 6
move 6 from 8 to 2
move 2 from 4 to 5
move 2 from 3 to 7
move 11 from 1 to 4
move 6 from 6 to 1
move 3 from 5 to 3
move 5 from 9 to 8
move 1 from 2 to 3
move 2 from 7 to 9
move 7 from 1 to 2
move 1 from 5 to 3
move 1 from 5 to 3
move 5 from 8 to 5
move 3 from 5 to 4
move 1 from 1 to 7
move 1 from 3 to 8
move 2 from 6 to 3
move 3 from 3 to 4
move 1 from 6 to 2
move 5 from 4 to 2
move 2 from 5 to 3
move 2 from 7 to 1
move 1 from 8 to 1
move 7 from 1 to 7
move 4 from 4 to 2
move 7 from 4 to 1
move 10 from 1 to 5
move 10 from 5 to 2
move 11 from 2 to 3
move 1 from 1 to 6
move 1 from 4 to 7
move 4 from 7 to 1
move 6 from 2 to 5
move 2 from 1 to 3
move 1 from 9 to 5
move 2 from 9 to 6
move 1 from 6 to 1
move 3 from 5 to 4
move 20 from 3 to 9
move 3 from 7 to 1
move 3 from 5 to 2
move 3 from 4 to 8
move 3 from 1 to 3
move 3 from 1 to 2
move 2 from 6 to 1
move 10 from 9 to 6
move 6 from 6 to 7
move 4 from 6 to 3
move 11 from 2 to 6
move 1 from 8 to 9
move 13 from 2 to 3
move 1 from 1 to 9
move 1 from 9 to 4
move 1 from 8 to 2
move 1 from 8 to 2
move 4 from 7 to 8
move 8 from 6 to 9
move 3 from 2 to 3
move 3 from 8 to 4
move 11 from 9 to 2
move 7 from 9 to 6
move 1 from 1 to 5
move 4 from 4 to 9
move 21 from 3 to 1
move 1 from 3 to 9
move 7 from 6 to 3
move 6 from 1 to 2
move 13 from 1 to 5
move 2 from 1 to 2
move 3 from 9 to 3
move 2 from 2 to 3
move 2 from 6 to 4
move 3 from 3 to 5
move 13 from 5 to 2
move 5 from 3 to 4
move 2 from 7 to 9
move 2 from 4 to 2
move 1 from 3 to 8
move 1 from 6 to 1
move 4 from 3 to 7
move 2 from 5 to 7
move 1 from 7 to 2
move 1 from 5 to 9
move 4 from 7 to 8
move 1 from 1 to 9
move 6 from 8 to 1
move 4 from 4 to 8
move 25 from 2 to 9
move 1 from 4 to 3
move 1 from 3 to 7
move 4 from 8 to 1
move 1 from 7 to 4
move 3 from 1 to 6
move 5 from 2 to 1
move 1 from 5 to 1
move 1 from 4 to 1
move 24 from 9 to 6
move 9 from 1 to 6
move 1 from 5 to 6
move 1 from 1 to 9
move 1 from 2 to 8
move 1 from 8 to 1
move 3 from 1 to 8
move 36 from 6 to 3
move 2 from 7 to 3
move 1 from 2 to 5
move 1 from 5 to 2
move 1 from 6 to 2
move 10 from 3 to 2
move 3 from 8 to 2
move 1 from 1 to 7
move 2 from 2 to 6
move 10 from 9 to 1
move 2 from 6 to 4
move 13 from 3 to 4
move 8 from 3 to 7
move 8 from 1 to 2
move 5 from 3 to 8
move 3 from 1 to 9
move 1 from 7 to 1
move 7 from 4 to 5
move 1 from 1 to 2
move 14 from 2 to 6
move 2 from 7 to 2
move 8 from 4 to 8
move 3 from 7 to 9
move 2 from 9 to 8
move 2 from 7 to 1
move 1 from 7 to 8
move 1 from 6 to 8
move 1 from 9 to 3
move 4 from 2 to 7
move 6 from 6 to 1
move 3 from 1 to 9
move 1 from 1 to 7
move 6 from 5 to 6
move 1 from 5 to 2
move 1 from 6 to 8
move 5 from 7 to 5
move 1 from 2 to 9
move 2 from 3 to 4
move 9 from 8 to 4
move 8 from 4 to 8
move 6 from 6 to 7
move 5 from 6 to 4
move 7 from 9 to 7
move 7 from 8 to 7
move 5 from 8 to 4
move 3 from 1 to 6
move 1 from 2 to 7
move 1 from 1 to 4
move 4 from 5 to 2
move 2 from 6 to 9
move 1 from 3 to 7
move 1 from 5 to 1
move 1 from 8 to 9
move 1 from 6 to 1
move 1 from 2 to 7
move 2 from 8 to 1
move 2 from 1 to 8
move 3 from 2 to 4
move 1 from 6 to 1
move 17 from 4 to 1
move 3 from 2 to 7
move 13 from 7 to 8
move 1 from 2 to 6
move 14 from 1 to 4
move 2 from 8 to 5
move 1 from 9 to 7
move 2 from 5 to 4
move 1 from 9 to 3
move 5 from 1 to 5
move 3 from 4 to 1
move 1 from 3 to 2
move 7 from 4 to 5
move 9 from 7 to 8
move 5 from 4 to 2
move 1 from 1 to 3
move 1 from 9 to 2
move 15 from 8 to 6
move 1 from 3 to 7
move 11 from 6 to 5
move 1 from 4 to 8
move 3 from 1 to 7
move 5 from 7 to 5
move 27 from 5 to 1
move 8 from 8 to 4
move 1 from 2 to 6
move 3 from 6 to 1
move 9 from 1 to 5
move 5 from 5 to 7
move 2 from 2 to 1
move 2 from 5 to 4
move 6 from 7 to 6
move 1 from 5 to 2
move 1 from 7 to 8
move 4 from 6 to 8
move 5 from 6 to 3
move 1 from 7 to 1
move 5 from 4 to 3
move 6 from 8 to 2
move 1 from 7 to 8
move 2 from 8 to 9
move 10 from 3 to 5
move 9 from 5 to 2
move 3 from 4 to 8
move 1 from 5 to 7
move 2 from 9 to 7
move 2 from 8 to 3
move 1 from 3 to 8
move 19 from 1 to 7
move 4 from 2 to 7
move 2 from 4 to 3
move 3 from 3 to 2
move 2 from 8 to 3
move 2 from 5 to 8
move 1 from 2 to 3
move 2 from 8 to 3
move 5 from 2 to 5
move 9 from 7 to 5
move 13 from 5 to 9
move 7 from 2 to 6
move 2 from 6 to 9
move 1 from 2 to 1
move 5 from 6 to 7
move 1 from 5 to 7
move 6 from 1 to 2
move 5 from 3 to 6
move 6 from 7 to 2
move 3 from 6 to 4
move 3 from 7 to 4
move 12 from 7 to 6
move 5 from 4 to 1
move 2 from 7 to 4
move 3 from 4 to 6
move 16 from 6 to 3
move 4 from 1 to 4
move 1 from 1 to 9
move 3 from 9 to 2
move 1 from 4 to 6
move 9 from 3 to 7
move 2 from 6 to 3
move 3 from 3 to 9
move 15 from 2 to 7
move 19 from 7 to 4
move 15 from 9 to 2
move 16 from 2 to 8
move 6 from 3 to 5
move 4 from 7 to 5
move 15 from 8 to 7
move 19 from 4 to 2
move 1 from 8 to 3
move 16 from 2 to 1
move 9 from 7 to 6
move 7 from 2 to 8
move 2 from 2 to 7
move 1 from 9 to 5
move 1 from 3 to 4
move 6 from 1 to 2
move 8 from 5 to 1
move 1 from 5 to 1
move 18 from 1 to 8
move 7 from 7 to 5
move 7 from 5 to 3
move 4 from 3 to 6
move 13 from 8 to 5
move 12 from 8 to 1
move 5 from 1 to 6
move 15 from 5 to 4
move 1 from 1 to 6
move 12 from 6 to 3
move 8 from 3 to 4
move 2 from 7 to 3
move 9 from 3 to 1
move 5 from 2 to 9
move 16 from 4 to 3
move 10 from 1 to 3
move 2 from 1 to 5
move 1 from 3 to 1
move 5 from 6 to 1
move 4 from 9 to 3
move 1 from 2 to 8
move 1 from 8 to 1
move 1 from 9 to 8
move 2 from 5 to 9
move 9 from 4 to 1
move 3 from 1 to 3
move 2 from 6 to 8
move 3 from 8 to 5
move 2 from 1 to 5
move 2 from 9 to 8
move 1 from 8 to 6
move 2 from 5 to 3
move 19 from 3 to 1
move 2 from 4 to 2
move 1 from 5 to 6
move 2 from 2 to 3
move 1 from 8 to 6
move 8 from 3 to 9
move 6 from 3 to 7
move 2 from 6 to 2
move 1 from 6 to 1
move 1 from 1 to 8
move 1 from 8 to 9
move 1 from 7 to 3
move 19 from 1 to 5
move 21 from 5 to 2
move 13 from 2 to 6
move 13 from 1 to 8
move 7 from 9 to 7
move 2 from 9 to 2
move 10 from 8 to 3
move 1 from 1 to 6
move 10 from 2 to 4
move 11 from 3 to 5
move 8 from 5 to 6
move 1 from 3 to 7
move 2 from 8 to 6
move 2 from 2 to 8
move 3 from 7 to 6
move 2 from 8 to 6
move 1 from 1 to 2
move 24 from 6 to 5
move 2 from 3 to 8
move 1 from 8 to 6
move 7 from 7 to 9
move 4 from 6 to 9
move 1 from 8 to 9
move 21 from 5 to 9
move 2 from 7 to 2
move 1 from 8 to 5
move 1 from 7 to 3
move 12 from 9 to 6
move 6 from 6 to 3
move 12 from 9 to 4
move 4 from 5 to 6
move 13 from 4 to 2
move 8 from 4 to 8
move 10 from 6 to 8
move 11 from 8 to 9
move 4 from 8 to 4
move 2 from 4 to 3
move 8 from 3 to 8
move 2 from 6 to 8
move 1 from 3 to 8
move 6 from 2 to 4
move 1 from 4 to 8
move 1 from 9 to 7
move 13 from 8 to 4
move 1 from 7 to 1
move 1 from 1 to 4
move 8 from 4 to 7
move 3 from 5 to 7
move 19 from 9 to 7
move 3 from 2 to 7
move 1 from 8 to 2
move 13 from 7 to 6
move 1 from 2 to 4
move 4 from 6 to 2
move 1 from 8 to 3
move 7 from 6 to 8
move 1 from 6 to 2
move 1 from 2 to 7
move 9 from 2 to 3
move 1 from 6 to 2
move 21 from 7 to 5
move 9 from 5 to 3
move 19 from 3 to 9
move 5 from 8 to 5
move 2 from 2 to 1
move 2 from 1 to 8
move 6 from 4 to 5
move 3 from 8 to 7
move 15 from 9 to 2
move 2 from 2 to 5
move 3 from 9 to 6
move 5 from 4 to 5
move 11 from 2 to 6
move 1 from 8 to 6
move 1 from 9 to 5
move 1 from 7 to 3
move 6 from 5 to 6
move 1 from 4 to 6
move 1 from 3 to 4
move 13 from 5 to 2
move 16 from 6 to 9
move 4 from 4 to 5
move 2 from 6 to 2
move 2 from 6 to 4
move 2 from 4 to 5
move 2 from 7 to 8
move 2 from 6 to 3
move 2 from 5 to 8
move 14 from 5 to 7
move 4 from 8 to 1
move 4 from 1 to 6
move 1 from 3 to 9
move 1 from 6 to 1
move 2 from 7 to 3
move 2 from 3 to 7
move 2 from 5 to 2
move 9 from 9 to 2
move 13 from 7 to 3
move 12 from 3 to 9
move 2 from 6 to 8
move 14 from 2 to 9
move 2 from 8 to 9
move 10 from 2 to 1
move 1 from 7 to 4
move 2 from 3 to 8
move 4 from 2 to 1
move 1 from 8 to 3
move 1 from 2 to 6
move 1 from 8 to 3
move 4 from 9 to 4
move 1 from 3 to 5
move 1 from 5 to 1
move 1 from 3 to 9
move 12 from 1 to 8
move 10 from 8 to 5
move 7 from 5 to 6
move 1 from 1 to 9
move 3 from 5 to 1
move 1 from 1 to 3
move 16 from 9 to 7
move 4 from 4 to 3
move 1 from 4 to 9
move 15 from 7 to 8
move 15 from 9 to 1
move 8 from 1 to 6
move 1 from 9 to 3
move 17 from 6 to 2
move 1 from 9 to 1
move 15 from 2 to 7
move 14 from 8 to 9
move 12 from 7 to 9
move 12 from 9 to 3
move 3 from 7 to 9
move 1 from 7 to 4
move 7 from 9 to 6
move 1 from 4 to 6
move 11 from 9 to 6
move 2 from 1 to 2
move 18 from 6 to 4
move 4 from 2 to 7
move 2 from 7 to 3
move 2 from 7 to 8
move 4 from 1 to 5
move 1 from 9 to 2
move 2 from 5 to 4
move 5 from 1 to 3
move 2 from 3 to 7
move 2 from 3 to 9
move 1 from 6 to 7
move 1 from 2 to 9
move 2 from 8 to 1
move 3 from 1 to 3
move 2 from 5 to 8
move 2 from 3 to 5
move 1 from 5 to 2
move 1 from 1 to 3
move 1 from 9 to 2
move 1 from 9 to 1
move 3 from 7 to 6
move 1 from 1 to 9
move 2 from 8 to 9
move 1 from 2 to 3
move 2 from 8 to 2
move 2 from 6 to 5
move 1 from 8 to 5
move 3 from 2 to 5
move 3 from 4 to 8
move 1 from 8 to 2
move 3 from 9 to 7
move 3 from 7 to 1
move 1 from 9 to 6
move 3 from 1 to 2
move 2 from 8 to 7
move 2 from 7 to 9
move 2 from 6 to 5
move 3 from 5 to 3
move 1 from 2 to 5
move 3 from 2 to 7
move 2 from 5 to 6
move 15 from 4 to 9
move 1 from 3 to 1
move 25 from 3 to 4
move 3 from 7 to 3
move 5 from 9 to 5
move 10 from 9 to 5
move 9 from 5 to 1
move 5 from 5 to 2
move 1 from 6 to 7
move 5 from 5 to 8

1
inputs/day06.txt Normal file
View File

@@ -0,0 +1 @@
nfddjzjjjmrjjfttzctzzhqzqbbvhhcfcpcqpcqpccsmsvsswbwzwfffnvfvpfvffhnnrgngzgrrhvhfhvvmjvjcccvppqdppbnbjjzlzflfccjjtctqccrhrnhnqhqwwjssjjhpjjcqqdgghddhfdfbffdpfdfzdddthhrcrbrqrbqqbcbnnwbbzcbzccmqqwllrljjjpqpdpsddmbmccwwgngmmzzzpbpspnprnppprmmwfwffrrpsrrchrrrrdqdfddnvnjnppqmqhhpshhjmhjhzjhhhzllbpbnnngdgzgmmjvvprrhqrhqhpqhqqrnqnddvjvvftfggfcgfffgrghhbmbzzjczzcscrccgbbjbqjbjsbsqbqttbqbfqqqrzrmzrmmcwcmwmrwmwnmnfnjjbdjbbslltjjmgmrmllhbhsbsmsqmqllvjjrvjrjcrrtztjzjbjsbbrjjvbjjgqjjpjsszpszsnznllvmlmfmppbvbzvvddtbtrbttchthjthjhnjnqnqrrllnflnnljnnzjjswjwllpmmpnnqnrrndnnbwwmcmcmbbhjjbbfpfvpvttcvvhshqqznzqqdndldmllpgptgptpbblzlddgqqdmmvpvvrccfvvjrvjjgpggqcggjbgbqqcgqccgppffjppzczmzdmmqppwcwlcwwhccfpcphcctvtzthtzhhnmnvmnnvqnqnpnqqwqsqdsszwzbwwgcwcrrtprrfhhcmcqcdcvdcccnpptgpgwpprsprsrdrtdrtrntrtprtppstsccbwwvnvpnvpnptpqttzbzcznzhzhddfbflfcchvchhplhlwhhlhglhhwqqzlqzlzvlvtlvtvrttglttslslclslqssslclbbrjrpjjcscfsfppjlplhplptlltlflglffdttmffrggfjjmllbnlnbnznqnfffmhhnmmsgmsmfsszggpnnhmhnnpwnndqqlmqmnmtnmtnttvtztlzlnzzsdsnssvhsszcscffcpczpcpffpwfwnwhnntnssptthccbnndppgjgpjpssbnnpgnpppjtjqqzfqqrrbmmbdddzjzvzwzssnpsnspnpvnpppjppvsvffmpffbcffslfsfmsmmqzzmttnsnqsqcsqsbqbcclqqphpttvrtrlrhrthhlppscsrsjjvljlmlwlslblqqqgdsbrzwzjzwcjrwbpfmjtmdgjvbcfvtvmsfjtjcmtlzmsjlnmhcswcmjndggdsmqfmmdngjpvrsbhrchldnhdhfdlwccnfmgbwfzppgzzcvblvsmqbfghrgdwlzdcvpqthgbdlwbrfpsvlgpdqznftswgwvchjfrblbdsqjmzchfhlrjhpbrdgvgrrmhrnrdbrdsfsgzvqfdtnvddbtcjwphrhgpqlzjssrgzjcncjnbrzvhgbwpgtfnqhpspmgptzcgvjqgzpmwtjtzldqnclmplwdpzcppgcbrsnlzfgmlnljjhfzrftnhdfnqchgdqrfcjszvbmdrghwzmjnwgnrlptljzqrwsmcfwvbcjgsfdjhnqgzzztmcgmndbtdwvqmzlfcmhfgpqztwgjdccncdccpgbcvhfzbhhbjhgjpdzcmrwgtvrmzdwjtmlzllmgplpqjwwwvbrzgmvpcvwchcwfgbjtzrfctgvfrpphbnsbjlswrztqmchtzfstzdgdwwvhpdhztbmsrbqmndpgvnwwdtgzcddvmvbjstqmjvtzlzgrhzhvplwnpphctvtlvnpmwfzmqcvrnfmmgtsgbcjpffrvbpqpszfpjsjtzqmcnzhnjnpwtvgfqntnhhjhmbvmlvmqgggrnfmmmsvfsqffbvwtzlfhlbjqhrltzwfstvjqhbbblqdbcmgtjgmzdtpslbzsgnmpzsswjlwdpzpmmvmpntbhnqlwrcrfbghzhwlhhpjqztjjrrfscrtwtnlqlqmdbmbfnvngvvthhghgsvqlqvgvmtjmjtwpcznzqhhfpqqfphcdrtzjjhsffslthzwpmsnltnjmfgpsjgqzdwrtgnhflhrnjwqftpnqgptgvgjptzhhtqhtddsfhppmmqcrsnlnrswpjhqgzbpwzfzptzqzzwltlrmjwjrwdgvvzhshqqrhtzmvqpfljlvpmrzbqpscpvsfdbdbcbdwwhpmldlrgpwslzhtbpgtzscfhjlgwcgbhcbftpftvpggvcdvndqnfvfqbwrjtdcbwpsbqpzmwdhjpmjhjmlcdphrjbgsnmcmvfnrggfvttclmbvsfjpnbndbblnbdfqzmsldlswdrtzqsqppjshtlrtccthmmpjgddbbgfgthnzdffbtrpchzgbvqvjcsnpgbrzrczzmzrmhjrlvvgmsqddjsqmcqfmwnhznbczzjlpmhnfwjtrfgffsjdlwgdwwlvdpdlvszphntrvttczgnwffsdsvjmqbthgcgfjgznrfnbplbvgsjbsglhnrjpbldhmznqgqpvldvhcpmmwzfjdjdbnprtrrnwsszjhmngvmtsrqdqdsprwhjpsqwqbsdtpptwlbfbsvdgrplrvpnfbzwrdsdbvhpgwcnqvwdcswdmdltchnngpmlqvchbnrpzcnfhvlzbwbnmssbhpvvmpcwvrwzpfpssndwwfnrslpjwhwrfsswmgtszrhczcrclpldpwpghgptmzzjjjtvjcnncjpfbcvldbnlnqtsqdswcsrqcfgvwbwdvbdwwzndfvcstjbfngtqqwsbpdjdgqdlsnwgcvmmhrqcqvdbqdqczzwzlfgffbwzbfdnpvprzmqclllsdvctwjfgqbchhmsntlvnlspwtnhgshwrvzccfmfrscqwrvdccwqnrccctjrvvnqbrphrfvfrfldbbthhrdzvdmfbctsmvgwmvpdslgbcpqqdvpsjcdvmctwghdsjtmhhvdswbcvtmsnsztfghnnfhflmmnmdqpvpdplllzgqgnsjwsrgzfwhrwhcscvrgcrgjdghqjfbswtgjsvnpqznrvbdbrplwdmbqhtbcfccnpwqlsdstnpcfpbfgqrzmcqhflmcfvbbnwrrblnfslsrwpwlbvqfhgpdwzmgvftssrvdmhnmwdfqmsvqbltlmmwmjrrhgpgznqbwhcqgphvzqmntbbdhhpnlbbffjgmcdntgwmtblwlzrcdcdbtrllrdnznrrsglnwhtwbrfdrpvgqwsgzwghbtsfwqlchgsnvfmvnzntlsnlwrnjjltrpmhwnzmhrqdlvvzbfgwlwgdsgcjcjfvhbcjgzlqtsljvzcvlppqdszvdbsmgddrtmvbcpbpppcpvhzfsjrmtcpzljbhpnjjmcdwslrhslccpljrtvcscbcltpshpnrqvtdfzbbfqtpbvznvrbflwvbvrhqpzltsdrnqccsfgzzftvjfqslcnmfvwtpdbjhtzwrgvntgnfvqtdrjdgglvrnqfzsbhnvhcdbctthdrjnvwlcsjtmphpvlqjngwjnngmqqnslrrsdfpfbvsvcwjtfmwtbpnnghtvvwlphbnsgflvsfdcqrctvjfjrwqjdmbbcclwvlstbgbfqjgbpbqfwdbpmnvqnfpbhrfhwltmcszpwnvtvhrvpcqhzdppjwttlhgsnvmsrwrnwvgzpbwljjjsjzctftzftvmsstpjnzvmmrgbbpmfmfrszwjdgzfhpvsfdqbbhgvfvqrrtqwlwzwwsnnmmvmlwjzvgrwhmffzwrqwbcdtbtzpspbnqgprdqtzrpmgvnmbsnjnvtzgmhqqtrvltbsrwjlssncdppgpmzqzbzvbpjpfwmvgsbhffzpbctmqvfwhsgdjtwqhrhmgnqpvmpjzhppvcbrpwmdshzcrwzdzcjmhfvjgtbznsmdjphlssmlmbhtmnsqnjfsjwhjvgztnwhmnztqppchngdnhzwpsvqqpzdwgbhcbzvmbnqmghbhgvrqhtfzhgvqdbpvdrjsqrdnhqhrwdlczvtnzwfrqhnffwdvtrnqsmmcjtrhmgbwcmnzbbvdsrlbbtwslhghwprpglpq

1096
inputs/day07.txt Normal file

File diff suppressed because it is too large Load Diff

99
inputs/day08.txt Normal file
View File

@@ -0,0 +1,99 @@
301220120123412411222431204050154502352345215611331265331250145342122214525502214010044420343123123
212320323343022012341342154350405334001503310300211115153234405042152322215224432102400231113311111
201121301211224101311542432232543306541420361630235333011410624063304221040115102553044222124011231
232202332000223341510415415041456543552366532665005356434300206166046103153010034420344343011033113
210314434121343443320133105330346640420462134535200335545300063363254665242325230054401312222330003
230214144101224050540112215100230300363531055535606540515103053341534215435154012112140240124100110
231101440201215435252051416446206332423151420012651331143355655244262555053300034015013244122130030
214222212324200401052120065613545410604234254167572224245015316613164134265153313214432220442033121
010101140402334554220203222036634231512152221455263551635633346541265223541540132045335333002223424
141224023202512320500606623246021536434116717372527356442422357712253035560552010313145410243214244
342313244142203024440112330041036065142245413435573537671475271244610245022435212200405455551031300
400412431024553054563062232450106636227551743332536773246216563237746040260223025405240105550211342
141411114240054115626641115664417124644446553167127275573572277534716362414652422624302412000344204
304244002433112544632613515265757653216235741254644271315654143447247446415244144112322551315312440
034412130253154014325430531636135646423361675474554354114661252723134131331331364550211025331005110
203230120341502446443342636426563227647672423846477226654522546745461257167105415103340235011202102
000304220335434256006236536157317262616265763646677874377378263627235146376615515544066624323231543
101323340335206434552203561646466267426825854776848224328252384531177377727463300325223111432452044
443203522336150155435544744243555565545237722358736446652663532873525636261412225525550006103302105
024402111202046625261447262172117482763754324238438534828367456666385662441762475663425231012052231
304102502005006215165124145477583756557534848357388484458683773276743654452221742726125603631535221
102242345301310562362655166723276388782224434488345643223328875357434577377774571124062514515225323
243240452045506406233373246572828585355877339635749687859248246824648243733613635453456402505250303
012352100012020202464336343645745643432459668843833863555554453734885388527435724644214236030032234
502301551613053433631262457468258867289345397685878634954795338424484872426226353756723364155214515
423041536552451365166244244533646822743993898794997445777675763398844356245712374176524561556305525
425254640333051274352217364867636553657469538835745385349436985448743264485283366446114460665235412
451305136116044364536433362258776588858395555558784748933645435747556548238346672563734344020454302
432303643553065262322344228232565576689647769594849965393545794453967722354542675575263552410143115
134544203161553255673562273655895763938858688958546785546995776997839965834382885435545631503335420
555120002034333741674266784562695566888447446849894657668489395353895595526886884344327466141516541
513443021302125256763465382844658763845358758869688948575985943473999357685734374175371446220146233
233366010551721127328385236556377437634587845849877758459689687794745477428788742731316465140405213
553011226633221264468324542499436483854879476698495899976485685488773948962325655755266442362003543
312310355415566137337775829643373677544476849477957567497649568966978435833576736386411214630355151
553145403544542737764542375578459459765676558566476444687477445946459378969263463861117325515431032
536600400372417274463258586446436786877854445766879776549484448887448579549836737426771156120411052
030621320724121554684336878497569899885854988855858555775456559646495997979468273647347456245100543
545015312153425765287374339999948784855487886865776557656565676778594554989747852238614427623334041
203005461166615125245248633779856478585597855957589689986888656699549686966355478473725534436206000
552104352652311173347625849374448596777558588767888585799589875757945995549567776384722373626201524
103604131421156167438445367445944478744687879597557966758786897455674875666365253527343435256603601
300251364451465528673586486838569558457965667868668568797565799949548765587445748556373652351606135
203613231642774436372333986973765865968569869659668887695588756978695547464449478577546236167206025
000526564661714825335338489687486957856857855999788768958878987799494866538374633368677562673506424
515644525376577475566446984796979687487766955689666777875898796699874589553539884845683175752360631
221333616257462253823256375979645755896686997869696867698969958844999687686476364354576477345551111
105222627452134822874253968777797786579655789896697888689986866976775779378896326264363317162751623
162663173774176522666878887636864568989556887778997867979686869994994668955878548843786742723736203
532212411613465674686254989747549989687685879666668989986756655657544797785388372436622767147424660
061430341565238668884894448998884968886585676968898898887797795594859978795536965546586321556760355
204541545567555653452864338665675969797686696989669999697778587687445456986538478322446257552365541
655210032533533474674648398796577485555756797879766896878759679897748887646963922274775445666332035
053321357461466882342436934979474474786699989987686798866969688869574558588835762723624774536431166
425041634561312425882487676489694958795969757677677787687667668745846895668784782733254653163100605
344310214433422228424464935784566975876698858796887769889968969647689677947447477245223663363264353
012103166457117866567539896646478766886868755577978876887556878875797456794886958725574112516550415
413644241335211836757687384748875888457579756795867975569679769875958466759557667477876467665436364
162433152223317868882246466489998974769885556787595776775676788845855763393365742834482216655401026
500614243747242223556575388534395464699869895767665788787956594678957798795886862225721534637646212
242634342176667133277463595457877478984767787799769898889775888858895875758637368336261313356414300
223205560227474377478554997966367944497877689866899558856977656965547586747685382327221347441146226
322455466216143484536844779897496757954488957957898966886586675678888653535576477832464231615155324
242335461373333262738285294874587649485768768756859998965778556857697358467855263664166411126122653
442153320312725352645222487595939346478865868447588576959689664564667987947863564283733267742015623
314256435256635233868576887878636755678944665464484575684575697584575336547784452783535121441266154
223210513276524633887828464489635943745697744976674678945746697677399465735288783524413443155052460
414644344437711641625883235659985578977459597858484566679475486473855973896455735345552521314243015
303253565166734271425285323787763975858945897789759985997698796347779944885385552472565572215360642
554345026245552362643534848687345838937664445457956798786577433576566547626774284415241562551163504
311535565216661455148884287865768434966933844685584479978489494757874552577566854667712125345561545
415250611366327134655472756753545737584664446946696869669867693575365348285472261146676153654423343
245134635554051122723564642433875435935979656663668837797668649877868784674366711177437413214613242
550305433351016326452653747274646969964344344955633437473798845985852738832263655166223231013250350
412424612302616576262646757668355434555989468964573354645759674644744382678666232347542030341661053
242250452046136264165613485835446658933483399657658764964566438484376638324734716771116242431415343
215351034333540431527612622887846533476959369569746679337488463558585763464275533366551552100042055
435431152542541137277441543722662552265876998963863345653536848472468446825623116641634431511341415
512310146424650645726632222733373758536677539594973344357244627586436388227315222723436261011354444
415342343465665344577661441528646685383427283566766246753572785343237264536223626355350051400140114
241050242115325145031526345615255855442353746482385388835847843772354575412177127416310323254520420
020220124435411053633257436463635336832525634734264453487345354485334651724244114546332526244014343
233144204333151340325721264561431226263673564625645257644453365842865136737725510345534241014450104
214445105522101254615065716656473235246624687543865265286684547535626265545173540645424255433043332
131141005503150612140634466735217613138345322342853334247734784516716553114671206254014513103241500
120132523034235121510330646154142646314331362452535865757484632521317751341716362446121030453315304
222332342104255141541516053742767376342422671752664587373155226235757465552063266050454310555023234
130022331402524533534126360254271165656147565354323324127344143267561232655640150546201542425232423
041244331331204304551224525323327646371114744734661445454712776141442460245244062010323033300223040
314114011311133543043561246666161424252355464267753775116255217554737010132161163160333313105310431
241411310012501313224133414363533552666555416611756217364167127132203511115524044001111200411313443
214302012402443103350331642331524446633763473467453377136566732405003511614151100044055214231314311
010202242015444310420164245052526156300412151526245266534126364115514456545426434302254122342301411
011423214303322230335200221004343440314264121472144246346134341155334411654112313203311044301330344
301224314420311045034445523602316023152013003056146213152100641500545520504415031222210033304041411
220214142234023331303304444234306015540260423514533053233166213614214141332141350123320443304043021
012034313114122310325254321150626562505200402655111220563433533535445241355033442330140121212324203
132300421231302002541021054032536231430015654305433356436004156146330254151224453535144411201021112
011201113143220302144232532235500205436316601263264003140631445266055502252414045114101420043032302

2000
inputs/day09.txt Normal file

File diff suppressed because it is too large Load Diff

137
inputs/day10.txt Normal file
View File

@@ -0,0 +1,137 @@
noop
addx 7
addx -1
addx -1
addx 5
noop
noop
addx 1
addx 3
addx 2
noop
addx 2
addx 5
addx 2
addx 10
addx -9
addx 4
noop
noop
noop
addx 3
addx 5
addx -40
addx 26
addx -23
addx 2
addx 5
addx 26
addx -35
addx 12
addx 2
addx 17
addx -10
addx 3
noop
addx 2
addx 3
noop
addx 2
addx 3
noop
addx 2
addx 2
addx -39
noop
addx 15
addx -12
addx 2
addx 10
noop
addx -1
addx -2
noop
addx 5
noop
addx 5
noop
noop
addx 1
addx 4
addx -25
addx 26
addx 2
addx 5
addx 2
noop
addx -3
addx -32
addx 1
addx 4
addx -2
addx 3
noop
noop
addx 3
noop
addx 6
addx -17
addx 27
addx -7
addx 5
addx 2
addx 3
addx -2
addx 4
noop
noop
addx 5
addx 2
addx -39
noop
noop
addx 2
addx 5
addx 3
addx -2
addx 2
addx 11
addx -4
addx -5
noop
addx 10
addx -18
addx 19
addx 2
addx 5
addx 2
addx 2
addx 3
addx -2
addx 2
addx -37
noop
addx 5
addx 4
addx -1
noop
addx 4
noop
noop
addx 1
addx 4
noop
addx 1
addx 2
noop
addx 3
addx 5
noop
addx -3
addx 5
addx 5
addx 2
addx 3
noop
addx -32
noop

55
inputs/day11.txt Normal file
View File

@@ -0,0 +1,55 @@
Monkey 0:
Starting items: 56, 52, 58, 96, 70, 75, 72
Operation: new = old * 17
Test: divisible by 11
If true: throw to monkey 2
If false: throw to monkey 3
Monkey 1:
Starting items: 75, 58, 86, 80, 55, 81
Operation: new = old + 7
Test: divisible by 3
If true: throw to monkey 6
If false: throw to monkey 5
Monkey 2:
Starting items: 73, 68, 73, 90
Operation: new = old * old
Test: divisible by 5
If true: throw to monkey 1
If false: throw to monkey 7
Monkey 3:
Starting items: 72, 89, 55, 51, 59
Operation: new = old + 1
Test: divisible by 7
If true: throw to monkey 2
If false: throw to monkey 7
Monkey 4:
Starting items: 76, 76, 91
Operation: new = old * 3
Test: divisible by 19
If true: throw to monkey 0
If false: throw to monkey 3
Monkey 5:
Starting items: 88
Operation: new = old + 4
Test: divisible by 2
If true: throw to monkey 6
If false: throw to monkey 4
Monkey 6:
Starting items: 64, 63, 56, 50, 77, 55, 55, 86
Operation: new = old + 8
Test: divisible by 13
If true: throw to monkey 4
If false: throw to monkey 0
Monkey 7:
Starting items: 79, 58
Operation: new = old + 6
Test: divisible by 17
If true: throw to monkey 1
If false: throw to monkey 5

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 @@
...####..#.#.#....###..#....#..#..#...##..###..##.#...######.##....####
..#.##..#.#...###..###.##....#..##......#.###..###....#.#.#....#...#.#.
.##...#...####..####....#....#####.##.#.....#.#.#.#..#..#...####....###
.####..#.##...#.##..#.#...#..#..##.######.#######.###.##.....####.#.##.
##.##.#..######.####..##...##.#.##...###.###..#.#..####..##...###.##.#.
...###.#.###..####..###.##..#..###..#..##.###.##.##....##...##.#.#..##.
###.##...#...#.#..####..##.#..###.##..#..##.#...#...##..##..##.##.###.#
..##....###.##.#...#####.#.#.###.#.#.#.##.#...#####.#####.....###.....#
#.####.#...#.#...##..#..#.#...###.#.####.#..##..##.#.###...#.####....##
#.##...#.#####...##....##..###..#...##.###..#.#.##.##.....#####....#...
#...#..#..#.#...##..#####.#.###......##..##.##.##...###..###...#..###..
..#.##.#..##.##.####.....#.###..#..#..#...###.###..#.#.##.##..#####..##
.##.#...#.....####......#.#..#..#.#....#.#...####...##.#.#.....#.#.....
#..#.##..###..#.....#.###..#.#..........##.......##.##.#..######...###.
.#...##.#.#...##.####..######.###.#.#.#.####.##.###..#...###.#..#..##.#
#.#.##.#.###..##.###.##.....###.#.#...#...###.##.#.#.##.##.#####.....#.
.#...###.##...#.##.#.###.###.##......##...##.#.###..#..#.#.##...####.#.
.#.#.##..#...#.##..#..##.....#....#....#.###....#########..#.#.########
.#.##..###..##..#.......##.##..#..###.#.##.####....#..#.#...##..##.#...
#####.##.#.....#.##...#.#...#.#.####..####....#.#...#.....###...##.....
..###....#....##...#.#...###....##.###.#.#...##..##.#..#.##....#.#.#.##
########..####...#.#..##.###...##.#...#...#.######...#..#..#..#...#..##
#.#....##...##..#...#....#.##....#.###.##.#...###.#..#.#.#...###..#.#.#
#.##........#..##...#...##.##.###.#.##...##...#####.#.#.....####.#.#..#
##.##...####.##.#...#....#...###.#...#....#.#.#.####...#.#....#.####.#.
.###....#..#.#..#..####..###.#.#..#.#..#.####..#####..#.#.#..#.....##.#
.#####.#.##.###......#..##.#.....#######..##.##.#####....#..#.#..####.#
.#....###....#.##..##.#.#.#.....#####..#.#.#.##...#.#....#.##..##....#.
####....####...#.#...#..##....#.#.#.###..#.######.##..##..######...#.#.
.#..####..#####.###..#..##.#.####.##.##..#.###..#...##.#...#.#.#.#.#.##
#.###########.####.....###.#..#...###.#######...#.#...##..###....#....#
#..#.####...###..####.#.##.#.#.#.#####.###.####...#...#....########..#.
#######.#..#.#..####.##.##..##.#...##..#######..#.#..#...#..##..#.###.#
##.#.....###.#..####.##..#.#######.#.#..#.##.#..###.##..##.##.#...#.#.#
#.#######.#.##.#.###.##.##...##..#.#....#.#.#..#.#..###..##.#.#.....##.
.##.##.#...####.#####.####.####.....#..####..#..##..###...#.#.###.#...#
.####...#..#.#.#.#........#..###...#####..####..##..######.###...#####.
###....#..##.##..#####....##.#..#...##.#####..#..###.#####..###.#..##.#
..#.#...#.##..#.##.####.####..#######....##....#.#....#.#.#..##.#.#..##
.#..#.########.........###.#.....###.######..#.######...####..#..#.#.##
.#.#...###...#.#.#.#..#...##.###.#.#.##.##.....####......##.#.#....##.#
..##..##...#.#######.#.##.####.###.#..#.....#.#..#...#..####..##..#.###
.#...####.##....###..#.###...###.##...###..######.#.#.#.#.#.#.#....#.##
.###..#.###.###..##.#..##..#.#.#...#..#.#..#...##..#..#...###...#####.#
#.#..#.#.#.....##..#.##..##.#.....#..###..#.#.#.#.#.#.##..#.####..##...
..#.#.####...#.##..##.##.####..##.#.#..##.#.###.#.######..#.######.#...
###.#.#.#.####..##.######.#.#...##......###..###.#..#...#...#.#..######
.###.#..#..######..##.####.###..##.#...#.#.#......###..##.#.#....#.#.#.
.##..#...#....#..###.##.#..#####.#.#....######..#....#..######.....#...
#.#...#..#.##...#..#..###.......####...#.####...#.#.#....#####.##...#.#
....#.####.#...#..#####.#..###..######.###.....#..#.#.#.#.#.##.#.##....
#.......#####.#.###..##.###..#####..#.###..#.....#.###.###..###..#.##.#
##.#.#....##.#.#..#..#...###.#..#.....###...###...#..#.######.#.#...##.
#....####.##.###....#....#....#...#..####...#.#.#.###..##.#.#..##.#..##
#.....#.##....###..####..##.#.......#..#.#.#.....#....####.#...#....###
###.#..####....#.....#..####....######.....#.#....#..###.#.#..#.#..###.
#..#.#.#...##....##.##....##.....#..####.###..##.#.#.##..#.##.###...###
....###.#.#.#..###.#.##.#.#.#.#####.#####..#..##...##.##.#...####.#.###
#####.....#.#.#.#.#.#.###.#####.#...#.##..#.#.##..##..###...#...#..##..
##.####.#.#.##..##.##.###....##.#..###.####..#######.#...##....#..##.##
##..#.####.##..#..#.#.#####.#.#.....#####..##..#.##.....##..#.#....##.#
.#..####...####.#####.##..#.##.....###.###.#.#.######..####.#...#..#.#.
##.####..##..#.....##.#.####..#..#....##...#....#####..##########.###.#
#...#.#.....#####.......###.#.#.#.###....#.#..#..#.##..#..#..#.####.###
##.###..#..##......##########....###..#######..#....#.#..###.##........
####.........#.#...##.#.#.#..#.#.####.#####....##...#.#.##.###..#.##.##
.####.#...#..#.##.####..##..#..#...##...........##..###.####..##..#.#..
.#####.##....##.#..####.##..##.#.###.....##.#..#..#.#.#...#.#...####...
#...####........#.##.####..##.....#####.#.#####.#####..#.##.#..##...##.
.###..###.####..###..##..##.#..##.###.#...#..#...#..#...#..#######.#.##
.#..#..##...##....##....####..#....#.##.....#.##..#.#..#...#..##.#..#.#

2
rust-toolchain.toml Normal file
View File

@@ -0,0 +1,2 @@
[toolchain]
channel = "nightly"

View File

@@ -2,6 +2,6 @@ use std::fs;
use aoc2022::day01::process_part_1; use aoc2022::day01::process_part_1;
fn main() { fn main() {
let file = fs::read_to_string("./inputs/day1.txt").unwrap(); let file = fs::read_to_string("./inputs/day01.txt").unwrap();
println!("{}", process_part_1(&file)); println!("{}", process_part_1(&file));
} }

View File

@@ -2,6 +2,6 @@ use std::fs;
use aoc2022::day01::process_part_2; use aoc2022::day01::process_part_2;
fn main() { fn main() {
let file = fs::read_to_string("./input.txt").unwrap(); let file = fs::read_to_string("./inputs/day01.txt").unwrap();
println!("{}", process_part_2(&file)); println!("{}", process_part_2(&file));
} }

View File

@@ -2,6 +2,6 @@ use aoc2022::day02::process_part_1;
use std::fs; use std::fs;
fn main() { fn main() {
let file = fs::read_to_string("./inputs/day2.txt").unwrap(); let file = fs::read_to_string("./inputs/day02.txt").unwrap();
println!("{}", process_part_1(&file)); println!("{}", process_part_1(&file));
} }

View File

@@ -2,6 +2,6 @@ use aoc2022::day02::process_part_2;
use std::fs; use std::fs;
fn main() { fn main() {
let file = fs::read_to_string("./inputs/day2.txt").unwrap(); let file = fs::read_to_string("./inputs/day02.txt").unwrap();
println!("{}", process_part_2(&file)); println!("{}", process_part_2(&file));
} }

7
src/bin/day03_1.rs Normal file
View File

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

7
src/bin/day03_2.rs Normal file
View File

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

7
src/bin/day04_1.rs Normal file
View File

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

7
src/bin/day04_2.rs Normal file
View File

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

7
src/bin/day05_1.rs Normal file
View File

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

7
src/bin/day05_2.rs Normal file
View File

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

7
src/bin/day06_1.rs Normal file
View File

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

7
src/bin/day06_2.rs Normal file
View File

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@@ -8,7 +8,7 @@ pub fn process_part_1(input: &str) -> u32 {
}) })
.max() .max()
.unwrap(); .unwrap();
return result; result
} }
pub fn process_part_2(input: &str) -> u32 { pub fn process_part_2(input: &str) -> u32 {

View File

@@ -37,7 +37,7 @@ pub fn process_part_1(input: &str) -> u32 {
.lines() .lines()
.map(|line| { .map(|line| {
let moves = line let moves = line
.split(" ") .split(' ')
.map(|s| s.parse::<Move>().unwrap()) .map(|s| s.parse::<Move>().unwrap())
.collect::<Vec<_>>(); .collect::<Vec<_>>();
match moves[1].partial_cmp(&moves[0]) { match moves[1].partial_cmp(&moves[0]) {
@@ -49,14 +49,14 @@ pub fn process_part_1(input: &str) -> u32 {
}) })
.sum(); .sum();
return result; result
} }
pub fn process_part_2(input: &str) -> u32 { pub fn process_part_2(input: &str) -> u32 {
let result = input let result = input
.lines() .lines()
.map(|line| { .map(|line| {
let moves = line.split(" ").collect::<Vec<_>>(); let moves = line.split(' ').collect::<Vec<_>>();
let opponent_move: Move = moves[0].parse().unwrap(); let opponent_move: Move = moves[0].parse().unwrap();
match moves[1] { match moves[1] {
"X" => { "X" => {
@@ -85,7 +85,7 @@ pub fn process_part_2(input: &str) -> u32 {
}) })
.sum(); .sum();
return result; result
} }
#[cfg(test)] #[cfg(test)]

61
src/day03.rs Normal file
View File

@@ -0,0 +1,61 @@
pub fn process_part_1(input: &str) -> u32 {
input
.lines()
.map(|line| {
let compartments = line.split_at(line.len() / 2);
let overlap = compartments
.0
.chars()
.find(|ch| compartments.1.contains(*ch))
.expect("There should be one overlapping item");
match overlap {
'a'..='z' => 1 + overlap as u32 - 'a' as u32,
'A'..='Z' => 27 + overlap as u32 - 'A' as u32,
_ => panic!("Invalid overlapping item"),
}
})
.sum()
}
pub fn process_part_2(input: &str) -> u32 {
let result = input
.lines()
.array_chunks::<3>()
.map(|[a, b, c]| {
let overlap = a
.chars()
.find(|chr| b.contains(*chr) && c.contains(*chr))
.unwrap();
match overlap {
'a'..='z' => 1 + overlap as u32 - 'a' as u32,
'A'..='Z' => 27 + overlap as u32 - 'A' as u32,
_ => panic!("Invalid overlapping item"),
}
})
.sum();
result
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &str = "vJrwpWtwJgWrhcsFMMfFFhFp
jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL
PmmdzqPrVvPwwTWBwg
wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn
ttgJtRGJQctTZtZT
CrZsJsPPZsGzwwsLwLmpwMDw";
#[test]
fn day1() {
assert_eq!(process_part_1(INPUT), 157);
}
#[test]
fn day2() {
assert_eq!(process_part_2(INPUT), 70);
}
}

75
src/day04.rs Normal file
View File

@@ -0,0 +1,75 @@
use std::ops::RangeInclusive;
use nom::IResult;
type RangePair = (RangeInclusive<u32>, RangeInclusive<u32>);
pub fn process_part_1(input: &str) -> usize {
let (_, assignments) = section_assignments(input).unwrap();
assignments
.iter()
.filter(|(a, b)| range_contains(a, b) || range_contains(b, a))
.count()
}
pub fn process_part_2(input: &str) -> usize {
let (_, assignments) = section_assignments(input).unwrap();
assignments
.iter()
.filter(|(a, b)| a.clone().into_iter().any(|n| b.contains(&n)))
.count()
}
fn range_contains(haystack: &RangeInclusive<u32>, needle: &RangeInclusive<u32>) -> bool {
haystack.contains(needle.start()) && haystack.contains(needle.end())
}
fn section_assignments(input: &str) -> IResult<&str, Vec<RangePair>> {
use nom::character::complete::newline;
use nom::multi::separated_list1;
let (input, ranges) = separated_list1(newline, line)(input)?;
Ok((input, ranges))
}
fn line(input: &str) -> IResult<&str, RangePair> {
use nom::bytes::complete::tag;
let (input, start) = sections(input)?;
let (input, _) = tag(",")(input)?;
let (input, end) = sections(input)?;
Ok((input, (start, end)))
}
fn sections(input: &str) -> IResult<&str, RangeInclusive<u32>> {
use nom::bytes::complete::tag;
use nom::character::complete;
let (input, start) = complete::u32(input)?;
let (input, _) = tag("-")(input)?;
let (input, end) = complete::u32(input)?;
Ok((input, start..=end))
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &str = "2-4,6-8
2-3,4-5
5-7,7-9
2-8,3-7
6-6,4-6
2-6,4-8";
#[test]
fn day1() {
assert_eq!(process_part_1(INPUT), 2);
}
#[test]
fn day2() {
assert_eq!(process_part_2(INPUT), 4);
}
}

138
src/day05.rs Normal file
View File

@@ -0,0 +1,138 @@
use nom::branch::alt;
use nom::bytes::complete::tag;
use nom::character::complete;
use nom::character::complete::{alpha1, newline};
use nom::multi::{many1, separated_list1};
use nom::sequence::delimited;
use nom::IResult;
pub fn process_part_1(input: &str) -> String {
let (_, (mut stacks, _, moves)) = parse_crates(input).unwrap();
for m in moves {
for _ in 0..m.count {
let c = stacks[(m.from - 1) as usize]
.pop()
.expect("expected a crate");
stacks[(m.to - 1) as usize].push(c);
}
}
stacks
.iter_mut()
.map(|stack| stack.pop().unwrap_or(""))
.collect::<Vec<&str>>()
.join("")
}
pub fn process_part_2(input: &str) -> String {
let (_, (mut stacks, _, moves)) = parse_crates(input).unwrap();
for m in moves {
let from_stack = &mut stacks[(m.from - 1) as usize];
let mut boxes: Vec<&str> = from_stack
.drain((from_stack.len() - m.count as usize)..)
.collect();
stacks[(m.to - 1) as usize].append(&mut boxes);
}
stacks
.iter_mut()
.map(|stack| stack.pop().unwrap_or(""))
.collect::<Vec<&str>>()
.join("")
}
#[derive(Debug)]
struct Move {
count: u32,
from: u32,
to: u32,
}
type CrateStacks<'a> = Vec<Vec<&'a str>>;
fn parse_crates(input: &str) -> IResult<&str, (CrateStacks, Vec<u32>, Vec<Move>)> {
let (input, crates_transposed) = parse_crate_stacks(input)?;
let (input, _) = newline(input)?;
let (input, crate_numbers) = separated_list1(tag(" "), parse_crate_name)(input)?;
let (input, _) = many1(newline)(input)?; // newlines be gone
// [
// [ A, B, C ],
// [ D, E, _ ],
// ] => [ [D, A], [E, B], [C]
// (its transposed for pop() and push() magic :))
// it also unwraps all `None`'s from the lists
let crates: CrateStacks = (0..crates_transposed[0].len())
.map(|i| {
crates_transposed
.iter()
.map(|items| items[i])
.rev()
.flatten()
.collect()
})
.collect();
let (input, moves) = parse_moves(input)?;
Ok((input, (crates, crate_numbers, moves)))
}
fn parse_moves(input: &str) -> IResult<&str, Vec<Move>> {
separated_list1(newline, parse_move)(input)
}
fn parse_move(input: &str) -> IResult<&str, Move> {
let (input, _) = tag("move ")(input)?;
let (input, count) = complete::u32(input)?;
let (input, _) = tag(" from ")(input)?;
let (input, from) = complete::u32(input)?;
let (input, _) = tag(" to ")(input)?;
let (input, to) = complete::u32(input)?;
Ok((input, Move { count, from, to }))
}
fn parse_crate_name(input: &str) -> IResult<&str, u32> {
delimited(tag(" "), complete::u32, tag(" "))(input)
}
fn parse_crate_stacks(input: &str) -> IResult<&str, Vec<Vec<Option<&str>>>> {
separated_list1(newline, parse_crate_line)(input)
}
fn parse_crate_line(input: &str) -> IResult<&str, Vec<Option<&str>>> {
separated_list1(tag(" "), parse_crate_single)(input)
}
fn parse_crate_single(input: &str) -> IResult<&str, Option<&str>> {
let (input, maybe_crate) = alt((tag(" "), delimited(tag("["), alpha1, tag("]"))))(input)?;
match maybe_crate {
" " => Ok((input, None)),
_ => Ok((input, Some(maybe_crate))),
}
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &str = " [D]
[N] [C]
[Z] [M] [P]
1 2 3
move 1 from 2 to 1
move 3 from 1 to 3
move 2 from 2 to 1
move 1 from 1 to 2";
#[test]
fn day1() {
assert_eq!(process_part_1(INPUT), "CMZ");
}
#[test]
fn day2() {
assert_eq!(process_part_2(INPUT), "MCD");
}
}

54
src/day06.rs Normal file
View File

@@ -0,0 +1,54 @@
use std::collections::BTreeSet;
pub fn process_part_1(input: &str) -> usize {
find_unique_window_start(input, 4)
}
pub fn process_part_2(input: &str) -> usize {
find_unique_window_start(input, 14)
}
pub fn find_unique_window_start(input: &str, window_size: usize) -> usize {
window_size
+ input
.chars()
.collect::<Vec<_>>()
.windows(window_size)
.take_while(|x| x.iter().collect::<BTreeSet<_>>().len() != x.len())
.count()
}
#[cfg(test)]
mod tests {
use super::*;
const INPUTS: &[(&str, usize, usize)] = &[
("mjqjpqmgbljsphdztnvjfqwrcgsmlb", 7, 19),
("bvwbjplbgvbhsrlpgdmjqwftvncz", 5, 23),
("nppdvjthqldpwncqszvftbrmjlhg", 6, 23),
("nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg", 10, 29),
("zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw", 11, 26),
];
#[test]
fn day1() {
for (input, expected, _) in INPUTS {
assert_eq!(
process_part_1(input),
*expected,
"Expected input {input} to return {expected}"
);
}
}
#[test]
fn day2() {
for (input, _, expected) in INPUTS {
assert_eq!(
process_part_2(input),
*expected,
"Expected input {input} to return {expected}"
);
}
}
}

166
src/day07.rs Normal file
View File

@@ -0,0 +1,166 @@
use std::collections::BTreeMap;
use nom::branch::alt;
use nom::bytes::complete::{tag, take_till1};
use nom::character::complete::{newline, space1};
use nom::character::{complete, is_newline};
use nom::multi::separated_list1;
use nom::IResult;
pub fn process_part_1(input: &str) -> u32 {
let (_, commands) = parse_commands(input).unwrap();
let directories = build_directory_tree_from_commands(commands);
directories.values().filter(|&size| *size <= 100_000).sum()
}
pub fn process_part_2(input: &str) -> u32 {
let (_, commands) = parse_commands(input).unwrap();
let directories = build_directory_tree_from_commands(commands);
let total_space = 70_000_000;
let required_space = 30_000_000;
let current_space = total_space - *directories.get("").unwrap();
let wanted_space = required_space - current_space;
directories
.values()
.filter(|&size| *size >= wanted_space)
.copied()
.min()
.unwrap_or(0)
}
fn build_directory_tree_from_commands(commands: Vec<Command>) -> BTreeMap<String, u32> {
commands
.iter()
.fold((vec![], BTreeMap::new()), |(mut cwd, mut dirs), command| {
match command {
Command::Cd("/") => {
cwd = vec![];
}
Command::Cd("..") => {
cwd.pop();
}
Command::Cd(dir) => {
cwd.push(*dir);
}
Command::Ls(files) => {
// We don't actually care about individual files, just sum the files together
// so we aren't looking up the BTreeMap as often
let total_size = files
.iter()
.filter_map(|e| match e {
DirEntry::File { size, .. } => Some(size),
_ => None,
})
.sum();
for i in 0..=cwd.len() {
dirs.entry(cwd[..i].join("/"))
.and_modify(|f| *f += total_size)
.or_insert(total_size);
}
}
}
(cwd, dirs)
})
.1
}
#[derive(Debug)]
enum Command<'a> {
Cd(&'a str),
Ls(Vec<DirEntry<'a>>),
}
#[derive(Debug)]
enum DirEntry<'a> {
Dir(&'a str),
#[allow(dead_code)]
File {
name: &'a str,
size: u32,
},
}
fn parse_commands(input: &str) -> IResult<&str, Vec<Command>> {
separated_list1(newline, parse_command)(input)
}
fn parse_command(input: &str) -> IResult<&str, Command> {
let (input, _) = tag("$ ")(input)?;
alt((parse_cd, parse_ls))(input)
}
fn parse_cd(input: &str) -> IResult<&str, Command> {
let (input, _) = tag("cd")(input)?;
let (input, _) = space1(input)?;
let (input, arg) = parse_file_name(input)?;
Ok((input, Command::Cd(arg)))
}
fn parse_ls(input: &str) -> IResult<&str, Command> {
let (input, _) = tag("ls")(input)?;
let (input, _) = newline(input)?;
let (input, entries) =
separated_list1(tag("\n"), alt((parse_dir_entry_dir, parse_dir_entry_file)))(input)?;
Ok((input, Command::Ls(entries)))
}
fn parse_dir_entry_dir(input: &str) -> IResult<&str, DirEntry> {
let (input, _) = tag("dir ")(input)?;
let (input, name) = parse_file_name(input)?;
Ok((input, DirEntry::Dir(name)))
}
fn parse_dir_entry_file(input: &str) -> IResult<&str, DirEntry> {
let (input, size) = complete::u32(input)?;
let (input, _) = tag(" ")(input)?;
let (input, name) = parse_file_name(input)?;
Ok((input, DirEntry::File { name, size }))
}
fn parse_file_name(input: &str) -> IResult<&str, &str> {
take_till1(|c| is_newline(c as u8))(input)
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &str = "$ cd /
$ ls
dir a
14848514 b.txt
8504156 c.dat
dir d
$ cd a
$ ls
dir e
29116 f
2557 g
62596 h.lst
$ cd e
$ ls
584 i
$ cd ..
$ cd ..
$ cd d
$ ls
4060174 j
8033020 d.log
5626152 d.ext
7214296 k";
#[test]
fn day1() {
assert_eq!(process_part_1(INPUT), 95437);
}
#[test]
fn day2() {
assert_eq!(process_part_2(INPUT), 24933642);
}
}

79
src/day08.rs Normal file
View File

@@ -0,0 +1,79 @@
use itertools::Itertools;
pub fn process_part_1(input: &str) -> usize {
let trees = parse_trees(input);
let rows = trees.len();
let cols = trees[0].len();
(0..rows)
.cartesian_product(0..cols)
.filter(|&(row, col)| {
let height = trees[row][col];
(0..row).all(|i| trees[i][col] < height) // up
|| (row + 1..rows).all(|i| trees[i][col] < height) // down
|| (0..col).all(|i| trees[row][i] < height) // left
|| (col + 1..cols).all(|i| trees[row][i] < height) // right
})
.count()
}
pub fn process_part_2(input: &str) -> usize {
let trees = parse_trees(input);
let rows = trees.len();
let cols = trees[0].len();
(0..rows)
.cartesian_product(0..cols)
.map(|(row, col)| {
let height = trees[row][col];
let up = match (0..row).rev().position(|i| trees[i][col] >= height) {
Some(n) => n + 1,
None => row,
};
let down = match (row + 1..rows).position(|i| trees[i][col] >= height) {
Some(n) => n + 1,
None => rows - row - 1,
};
let left = match (0..col).rev().position(|i| trees[row][i] >= height) {
Some(n) => n + 1,
None => col,
};
let right = match (col + 1..cols).position(|i| trees[row][i] >= height) {
Some(n) => n + 1,
None => cols - col - 1,
};
up * down * left * right
})
.max()
.unwrap()
}
fn parse_trees(input: &str) -> Vec<Vec<u8>> {
input
.trim()
.split('\n')
.map(|i| i.chars().map(|c| c.to_digit(10).unwrap() as u8).collect())
.collect()
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &str = "30373
25512
65332
33549
35390";
#[test]
fn day1() {
assert_eq!(process_part_1(INPUT), 21);
}
#[test]
fn day2() {
assert_eq!(process_part_2(INPUT), 8);
}
}

115
src/day09.rs Normal file
View File

@@ -0,0 +1,115 @@
use std::collections::BTreeSet;
use std::str::FromStr;
use nom::bytes::complete::tag;
use nom::character::complete;
use nom::character::complete::{alpha1, newline};
use nom::combinator::map_res;
use nom::multi::separated_list1;
use nom::IResult;
pub fn process_part_1(input: &str) -> usize {
let (_, moves) = parse(input).unwrap();
let visited = simulate_rope(moves, 2);
visited.len()
}
pub fn process_part_2(input: &str) -> usize {
let (_, moves) = parse(input).unwrap();
let visited = simulate_rope(moves, 10);
visited.len()
}
fn simulate_rope(moves: Vec<(Direction, usize)>, rope_size: usize) -> BTreeSet<(i32, i32)> {
let all_moves = moves
.iter()
.flat_map(|&(dir, count)| itertools::repeat_n(dir, count));
let mut knots: Vec<(i32, i32)> = vec![(0, 0); rope_size];
let mut visited = BTreeSet::new();
for dir in all_moves {
match dir {
Direction::Left => knots[0].0 -= 1,
Direction::Right => knots[0].0 += 1,
Direction::Up => knots[0].1 += 1,
Direction::Down => knots[0].1 -= 1,
}
for i in 1..rope_size {
let dist_h = knots[i - 1].0 - knots[i].0;
let dist_v = knots[i - 1].1 - knots[i].1;
if dist_h.abs() > 1 || dist_v.abs() > 1 {
knots[i].0 += dist_h.signum();
knots[i].1 += dist_v.signum();
}
}
visited.insert(*knots.last().unwrap());
}
visited
}
#[derive(Copy, Clone, Debug)]
enum Direction {
Left,
Right,
Up,
Down,
}
impl FromStr for Direction {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"L" => Ok(Direction::Left),
"R" => Ok(Direction::Right),
"U" => Ok(Direction::Up),
"D" => Ok(Direction::Down),
_ => Err("Invalid direction".into()),
}
}
}
fn parse(input: &str) -> IResult<&str, Vec<(Direction, usize)>> {
separated_list1(newline, parse_line)(input)
}
fn parse_line(input: &str) -> IResult<&str, (Direction, usize)> {
let (input, direction) = map_res(alpha1, Direction::from_str)(input)?;
let (input, _) = tag(" ")(input)?;
let (input, count) = complete::u32(input)?;
Ok((input, (direction, count as usize)))
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &str = "R 4
U 4
L 3
D 1
R 4
D 1
L 5
R 2";
const INPUT2: &str = "R 5
U 8
L 8
D 3
R 17
D 10
L 25
U 20";
#[test]
fn day1() {
assert_eq!(process_part_1(INPUT), 13);
}
#[test]
fn day2() {
assert_eq!(process_part_2(INPUT2), 36);
}
}

264
src/day10.rs Normal file
View File

@@ -0,0 +1,264 @@
use nom::branch::alt;
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::IResult;
pub fn process_part_1(input: &str) -> i32 {
let (_, instructions) = parse_instructions(input).unwrap();
let mut x = 1;
let mut strengths: Vec<i32> = vec![];
let mut cycle = 1;
for instruction in instructions {
match instruction {
Instruction::AddX(v) => {
cycle += 1;
if (cycle + 20) % 40 == 0 {
strengths.push(cycle * x);
}
x += v;
}
Instruction::Noop => {}
}
cycle += 1;
if (cycle + 20) % 40 == 0 {
strengths.push(cycle * x);
}
}
strengths.iter().sum()
}
pub fn process_part_2(input: &str) -> String {
let window_width = 40;
let window_height = 6;
let (_, instructions) = parse_instructions(input).unwrap();
let mut x = 1;
let mut cycle = 1;
let mut buf = String::with_capacity((window_width + 1) * window_height);
for instruction in instructions {
draw(&mut buf, cycle, x);
match instruction {
Instruction::AddX(v) => {
cycle += 1;
draw(&mut buf, cycle, x);
x += v;
}
Instruction::Noop => {}
}
cycle += 1;
}
buf
}
// I've swapped the characters to something... more readable than the original '#' and '.'
fn draw(buf: &mut String, cycle: usize, x: i32) {
if x.abs_diff(((cycle - 1) % 40) as i32) < 2 {
buf.push('█');
} else {
buf.push(' ');
}
if (cycle) % 40 == 0 {
buf.push('\n');
}
}
#[derive(Debug)]
enum Instruction {
Noop,
AddX(i32),
}
fn parse_instructions(input: &str) -> IResult<&str, Vec<Instruction>> {
separated_list1(newline, parse_instruction)(input)
}
fn parse_instruction(input: &str) -> IResult<&str, Instruction> {
alt((map(tag("noop"), |_| Instruction::Noop), parse_addx))(input)
}
fn parse_addx(input: &str) -> IResult<&str, Instruction> {
let (input, _) = tag("addx ")(input)?;
let (input, value) = complete::i32(input)?;
Ok((input, Instruction::AddX(value)))
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &str = "addx 15
addx -11
addx 6
addx -3
addx 5
addx -1
addx -8
addx 13
addx 4
noop
addx -1
addx 5
addx -1
addx 5
addx -1
addx 5
addx -1
addx 5
addx -1
addx -35
addx 1
addx 24
addx -19
addx 1
addx 16
addx -11
noop
noop
addx 21
addx -15
noop
noop
addx -3
addx 9
addx 1
addx -3
addx 8
addx 1
addx 5
noop
noop
noop
noop
noop
addx -36
noop
addx 1
addx 7
noop
noop
noop
addx 2
addx 6
noop
noop
noop
noop
noop
addx 1
noop
noop
addx 7
addx 1
noop
addx -13
addx 13
addx 7
noop
addx 1
addx -33
noop
noop
noop
addx 2
noop
noop
noop
addx 8
noop
addx -1
addx 2
addx 1
noop
addx 17
addx -9
addx 1
addx 1
addx -3
addx 11
noop
noop
addx 1
noop
addx 1
noop
noop
addx -13
addx -19
addx 1
addx 3
addx 26
addx -30
addx 12
addx -1
addx 3
addx 1
noop
noop
noop
addx -9
addx 18
addx 1
addx 2
noop
noop
addx 9
noop
noop
noop
addx -1
addx 2
addx -37
addx 1
addx 3
noop
addx 15
addx -21
addx 22
addx -6
addx 1
noop
addx 2
addx 1
noop
addx -10
noop
noop
addx 20
addx 1
addx 2
addx 2
addx -6
addx -11
noop
noop
noop";
#[test]
fn day1() {
assert_eq!(process_part_1(INPUT), 13140);
}
#[test]
fn day2() {
assert_eq!(
process_part_2(INPUT),
"██ ██ ██ ██ ██ ██ ██ ██ ██ ██
███ ███ ███ ███ ███ ███ ███
████ ████ ████ ████ ████
█████ █████ █████ █████
██████ ██████ ██████ ████
███████ ███████ ███████
"
);
}
}

204
src/day11.rs Normal file
View File

@@ -0,0 +1,204 @@
use std::collections::VecDeque;
use itertools::Itertools;
use nom::branch::alt;
use nom::bytes::complete::tag;
use nom::character::complete;
use nom::character::complete::{newline, space1};
use nom::multi::separated_list1;
use nom::sequence::{delimited, preceded};
use nom::{IResult, Parser};
pub fn process_part_1(input: &str) -> usize {
let mut monkeys = parse(input).unwrap().1;
// Sadly we are doing concurrent array indexing in rust with borrows
for _round in 0..20 {
for monkey_id in 0..monkeys.len() {
while !monkeys[monkey_id].items.is_empty() {
// I'm relying on rust's magic 'figure out when we can drop this to make it work'
// here. This var can be dropped *just* before the last line of the block to make it
// so we aren't borrowing mutably twice.
let monkey = &mut monkeys[monkey_id];
monkey.num_inspected += 1;
let item = monkey.items.pop_front().unwrap();
let item = monkey.operation.execute(item) / 3;
let next_monkey_id = if item % monkey.test_mod == 0 {
monkey.target_true
} else {
monkey.target_false
};
monkeys[next_monkey_id].items.push_back(item);
}
}
}
monkeys
.iter()
.map(|monkey| monkey.num_inspected)
.sorted()
.rev()
.take(2)
.product()
}
pub fn process_part_2(input: &str) -> usize {
let mut monkeys = parse(input).unwrap().1;
// Since we only care for divisibility in tests, we can just modulo every item with
// the LCM of all tests. This allows all tests to check for eligibility without actually
// letting the number grow huge.
let lcm = monkeys
.iter()
.map(|x| x.test_mod)
.reduce(num::integer::lcm)
.unwrap();
for _round in 0..10000 {
for monkey_id in 0..monkeys.len() {
while !monkeys[monkey_id].items.is_empty() {
let monkey = &mut monkeys[monkey_id];
monkey.num_inspected += 1;
let item = monkey.items.pop_front().unwrap();
let item = monkey.operation.execute(item) % lcm;
let next_monkey_id = if item % monkey.test_mod == 0 {
monkey.target_true
} else {
monkey.target_false
};
monkeys[next_monkey_id].items.push_back(item);
}
}
}
monkeys
.iter()
.map(|monkey| monkey.num_inspected)
.sorted()
.rev()
.take(2)
.product()
}
#[derive(Debug)]
enum Operation {
Add(u64),
Multiply(u64),
MultiplySelf,
}
impl Operation {
fn execute(&self, item: u64) -> u64 {
match self {
Operation::Add(x) => item + x,
Operation::Multiply(x) => item * x,
Operation::MultiplySelf => item * item,
}
}
}
#[derive(Debug)]
struct Monkey {
items: VecDeque<u64>,
operation: Operation,
test_mod: u64,
target_true: usize,
target_false: usize,
num_inspected: usize,
}
fn parse(input: &str) -> IResult<&str, Vec<Monkey>> {
separated_list1(newline, parse_monkey)(input)
}
fn parse_monkey(input: &str) -> IResult<&str, Monkey> {
let (input, _id) = delimited(tag("Monkey "), complete::u64, tag(":\n"))(input)?;
let (input, items) = preceded(
space1,
delimited(
tag("Starting items: "),
separated_list1(tag(", "), complete::u64),
newline,
),
)(input)?;
let (input, operation) = delimited(space1, parse_operation, newline)(input)?;
let (input, test_mod) = preceded(
space1,
delimited(tag("Test: divisible by "), complete::u64, newline),
)(input)?;
let (input, target_true) = preceded(
space1,
delimited(tag("If true: throw to monkey "), complete::u64, newline),
)(input)?;
let (input, target_false) = preceded(
space1,
delimited(tag("If false: throw to monkey "), complete::u64, newline),
)(input)?;
Ok((
input,
Monkey {
items: VecDeque::from(items),
operation,
test_mod,
target_true: target_true as usize,
target_false: target_false as usize,
num_inspected: 0,
},
))
}
fn parse_operation(input: &str) -> IResult<&str, Operation> {
let (input, _) = tag("Operation: new = old ")(input)?;
alt((
tag("* old").map(|_| Operation::MultiplySelf),
preceded(tag("+ "), complete::u64).map(Operation::Add),
preceded(tag("* "), complete::u64).map(Operation::Multiply),
))(input)
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &str = "Monkey 0:
Starting items: 79, 98
Operation: new = old * 19
Test: divisible by 23
If true: throw to monkey 2
If false: throw to monkey 3
Monkey 1:
Starting items: 54, 65, 75, 74
Operation: new = old + 6
Test: divisible by 19
If true: throw to monkey 2
If false: throw to monkey 0
Monkey 2:
Starting items: 79, 60, 97
Operation: new = old * old
Test: divisible by 13
If true: throw to monkey 1
If false: throw to monkey 3
Monkey 3:
Starting items: 74
Operation: new = old + 3
Test: divisible by 17
If true: throw to monkey 0
If false: throw to monkey 1
";
#[test]
fn day1() {
assert_eq!(process_part_1(INPUT), 10605);
}
#[test]
fn day2() {
assert_eq!(process_part_2(INPUT), 2713310158);
}
}

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);
}
}

24
src/day24.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);
}
}

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

@@ -1,2 +1,28 @@
#![feature(iter_array_chunks)]
extern crate core;
pub mod day01; pub mod day01;
pub mod day02; pub mod day02;
pub mod day03;
pub mod day04;
pub mod day05;
pub mod day06;
pub mod day07;
pub mod day08;
pub mod day09;
pub mod day10;
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;