diff --git a/Cargo.lock b/Cargo.lock index ba878a1..11a7779 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,33 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "ahash" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + [[package]] name = "aho-corasick" version = "1.1.2" @@ -11,17 +38,24 @@ dependencies = [ "memchr", ] +[[package]] +name = "allocator-api2" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" + [[package]] name = "anyhow" -version = "1.0.75" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" +checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" [[package]] name = "aoc-2023" version = "0.1.0" dependencies = [ "anyhow", + "aochelpers", "array_tool", "fs-err", "itertools 0.12.0", @@ -33,6 +67,20 @@ dependencies = [ "regex", ] +[[package]] +name = "aochelpers" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ea35303e600d41b4cb596ba14a039e8f697a33819ab0210d0b6dc5cf7af87a9" +dependencies = [ + "anyhow", + "dirs", + "hashbrown", + "log", + "num", + "reqwest", +] + [[package]] name = "array_tool" version = "1.0.3" @@ -45,12 +93,82 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "backtrace" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base64" +version = "0.21.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" + +[[package]] +name = "bumpalo" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" + +[[package]] +name = "bytes" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" + +[[package]] +name = "cc" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", +] + [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + [[package]] name = "crossbeam-deque" version = "0.8.3" @@ -84,24 +202,100 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "dirs" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.48.0", +] + [[package]] name = "either" version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +[[package]] +name = "encoding_rs" +version = "0.8.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +dependencies = [ + "cfg-if", +] + [[package]] name = "equivalent" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +[[package]] +name = "errno" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "fastrand" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" + [[package]] name = "fixedbitset" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + [[package]] name = "fs-err" version = "2.11.0" @@ -111,6 +305,54 @@ dependencies = [ "autocfg", ] +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-io" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-core", + "futures-io", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + [[package]] name = "gcdx" version = "0.1.4" @@ -128,11 +370,127 @@ dependencies = [ "wasi", ] +[[package]] +name = "gimli" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" + +[[package]] +name = "h2" +version = "0.3.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d6250322ef6e60f93f9a2162799302cd6f68f79f6e5d85c8c16f14d1d958178" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "hashbrown" version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +dependencies = [ + "ahash", + "allocator-api2", +] + +[[package]] +name = "hermit-abi" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" + +[[package]] +name = "http" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "0.14.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + +[[package]] +name = "idna" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] [[package]] name = "indexmap" @@ -144,6 +502,12 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "ipnet" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" + [[package]] name = "itertools" version = "0.10.5" @@ -162,6 +526,21 @@ dependencies = [ "either", ] +[[package]] +name = "itoa" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" + +[[package]] +name = "js-sys" +version = "0.3.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" +dependencies = [ + "wasm-bindgen", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -183,6 +562,29 @@ version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" +[[package]] +name = "libredox" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +dependencies = [ + "bitflags 2.4.1", + "libc", + "redox_syscall", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" + +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + [[package]] name = "memchr" version = "2.6.4" @@ -198,6 +600,50 @@ dependencies = [ "autocfg", ] +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "miniz_oxide" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.48.0", +] + +[[package]] +name = "native-tls" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "num" version = "0.4.1" @@ -275,56 +721,173 @@ dependencies = [ ] [[package]] -name = "petgraph" -version = "0.6.4" +name = "num_cpus" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "fixedbitset", - "indexmap", + "hermit-abi", + "libc", ] [[package]] -name = "ppv-lite86" -version = "0.2.17" +name = "object" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +dependencies = [ + "memchr", +] [[package]] -name = "prime_factorization" -version = "1.0.4" +name = "once_cell" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61b43cd4d5e49fa3c769f72033129f07eeaa102c3db2aa11be0c7f1a0cb50f0c" -dependencies = [ - "itertools 0.10.5", - "num", - "rand", -] +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] -name = "rand" -version = "0.8.5" +name = "openssl" +version = "0.10.62" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +checksum = "8cde4d2d9200ad5909f8dac647e29482e07c3a35de8a13fce7c9c7747ad9f671" dependencies = [ + "bitflags 2.4.1", + "cfg-if", + "foreign-types", "libc", - "rand_chacha", - "rand_core", + "once_cell", + "openssl-macros", + "openssl-sys", ] [[package]] -name = "rand_chacha" -version = "0.3.1" +name = "openssl-macros" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ - "ppv-lite86", - "rand_core", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "rand_core" -version = "0.6.4" +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1665caf8ab2dc9aef43d1c0023bd904633a6a05cb30b0ad59bec2ae986e57a7" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "petgraph" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" +dependencies = [ + "fixedbitset", + "indexmap", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69d3587f8a9e599cc7ec2c00e331f71c4e69a5f9a4b8a6efd5b07466b9736f9a" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "prime_factorization" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61b43cd4d5e49fa3c769f72033129f07eeaa102c3db2aa11be0c7f1a0cb50f0c" +dependencies = [ + "itertools 0.10.5", + "num", + "rand", +] + +[[package]] +name = "proc-macro2" +version = "1.0.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "907a61bd0f64c2f29cd1cf1dc34d05176426a3f504a78010f08416ddb7b13708" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ @@ -351,6 +914,26 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "redox_users" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" +dependencies = [ + "getrandom", + "libredox", + "thiserror", +] + [[package]] name = "regex" version = "1.10.2" @@ -380,14 +963,613 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +[[package]] +name = "reqwest" +version = "0.11.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37b1ae8d9ac08420c66222fb9096fc5de435c3c48542bc5336c51892cffafb41" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-tls", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "serde", + "serde_json", + "serde_urlencoded", + "system-configuration", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + +[[package]] +name = "rustix" +version = "0.38.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" +dependencies = [ + "bitflags 2.4.1", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "ryu" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" + +[[package]] +name = "schannel" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "scopeguard" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "security-framework" +version = "2.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "serde" +version = "1.0.194" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b114498256798c94a0689e1a15fec6005dee8ac1f41de56404b67afc2a4b773" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.194" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3385e45322e8f9931410f01b3031ec534c3947d0e94c18049af4d9f9907d4e0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.111" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "socket2" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +dependencies = [ + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "syn" +version = "2.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1726efe18f42ae774cc644f330953a5e7b3c3003d3edcecf18850fe9d4dd9afb" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "tempfile" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" +dependencies = [ + "cfg-if", + "fastrand", + "redox_syscall", + "rustix", + "windows-sys 0.52.0", +] + +[[package]] +name = "thiserror" +version = "1.0.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.35.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "num_cpus", + "pin-project-lite", + "socket2", + "windows-sys 0.48.0", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "unicode-bidi" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "url" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac36a15a220124ac510204aec1c3e5db8a22ab06fd6706d881dc6149f8ed9a12" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" + +[[package]] +name = "web-sys" +version = "0.3.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + +[[package]] +name = "winreg" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + +[[package]] +name = "zerocopy" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/Cargo.toml b/Cargo.toml index f694cc5..5423fa5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ edition = "2021" [dependencies] anyhow = "1.0.66" +aochelpers = "0.6.1" array_tool = "1.0.3" fs-err = "2.9.0" itertools = "0.12.0" diff --git a/examples/day17.rs b/examples/day17.rs index 78accd1..8205c65 100644 --- a/examples/day17.rs +++ b/examples/day17.rs @@ -1,211 +1,127 @@ -use itertools::Itertools; -use std::{collections::*, iter}; +use std::{ + collections::{BinaryHeap, HashMap}, + error::Error, +}; -const INPUT: &str = include_str!("inputs/day17.txt"); -const TEST_INPUT: &str = include_str!("inputs/day17_test.txt"); -const CUSTOM_INPUT: &str = include_str!("inputs/day17_custom.txt"); - -type Co = (usize, usize); +use aochelpers::{parse_number_grid, Coordinate, Direction, ScoredItem}; -fn try_add(co: &Co, offset: (isize, isize), rows: usize, cols: usize) -> Option { - let row = co.0.checked_add_signed(offset.0); - let col = co.1.checked_add_signed(offset.1); - row.zip(col).filter(|&(row, col)| row < rows && col < cols) +const INPUT: &str = include_str!("inputs/day17.txt"); +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] +struct Crucible { + facing: Direction, + location: Coordinate, + steps_taken: i32, } -fn possible_steps( - to: Co, - path: &[Co], - rows: usize, - cols: usize, -) -> impl Iterator + '_ { - [(-1, 0), (1, 0), (0, -1), (0, 1)] - .into_iter() - // Avoid walls - .filter_map(move |offset| try_add(&to, offset, rows, cols)) - // Do not go backwards - .filter(|next| { - if path.len() <= 1 { - true - } else { - *next != path[path.len() - 2] - } - }) - // Do not revisit nodes in a given path (cycling paths are always longer than no cycles) - .filter(|next| !path.contains(next)) - // Avoid going more than 3 times in the same direction (note the 4th element from arriving on a given col or row) - .filter(|next| { - if path.len() <= 3 { - return true; - } - - let (rows, cols): (Vec, Vec) = path[path.len() - 4..] - .iter() - .chain(iter::once(next)) - .map(|&(r, c)| (r, c)) - .unzip(); +fn main() -> Result<(), Box> { + let grid: HashMap, i32> = parse_number_grid(INPUT); + println!("{}", part1(&grid, 0, 3)); + println!("{}", part1(&grid, 4, 10)); - !rows.windows(2).all(|w| w[0] == w[1]) && !cols.windows(2).all(|w| w[0] == w[1]) - }) + Ok(()) } -const VIZ: bool = true; - -fn dfs(co: Co, end: Co, cost: u32, global_min: &mut u32, path: &[Co], grid: &[Vec], d: usize) { - if VIZ { - for (y, row) in grid.iter().enumerate() { - for (x, c) in row.iter().enumerate() { - if co == (y, x) { - print!("*"); - } else { - print!("{c}"); - } - } - println!(); - } - } - - // If this path is costlier than global min, end the path - if cost > *global_min { - if VIZ { - println!("DIED"); - println!(); - } - return; - } +fn part1(grid: &HashMap, i32>, min_move: i32, max_move: i32) -> i32 { + let mut repeated_states = HashMap::new(); + let mut unconsidered = BinaryHeap::new(); - // If this path is at finish and its still cheaper than global min, record cost and end the path - if co == end { - *global_min = cost; - if VIZ { - println!("FINISHED"); - println!(); - } - return; - } + let goal = Coordinate { + x: grid.keys().map(|c| c.x).max().unwrap(), + y: grid.keys().map(|c| c.y).max().unwrap(), + }; - /*if d >= 10 { - if VIZ { - println!("MAXED"); - println!(); - } - return; - }*/ - - if VIZ { - println!(); - } - - // Find potential next steps - let mut potential_next = possible_steps(co, path, grid.len(), grid[0].len()).collect_vec(); - - // Optimize order - potential_next.sort_by(|a, b| grid[a.0][a.1].cmp(&grid[b.0][b.1])); - - potential_next.into_iter().for_each(|next| { - let mut npath = path.to_vec(); - npath.push(next); - let ncost = cost + grid[next.0][next.1]; - dfs(next, end, ncost, global_min, &npath, grid, d + 1) + unconsidered.push(ScoredItem { + cost: 0, + item: Crucible { + facing: Direction::East, + location: Coordinate { x: 0, y: 0 }, + steps_taken: 0, + }, }); -} - -fn init_dfs(start: Co, end: Co, grid: &[Vec]) -> u32 { - let mut min = u32::MAX; - dfs(start, end, 0, &mut min, &vec![start], grid, 0); - min -} - -#[derive(Clone, Eq, PartialEq)] -struct State { - co: Co, - cost: u32, - path: Vec, -} - -impl Ord for State { - fn cmp(&self, other: &Self) -> std::cmp::Ordering { - self.cost.cmp(&other.cost) - } -} - -impl PartialOrd for State { - fn partial_cmp(&self, other: &Self) -> Option { - Some(self.cmp(other)) - } -} - -fn dijkstra(start: Co, end: Co, grid: &[Vec]) -> u32 { - let mut heap = BinaryHeap::new(); - heap.push(State { - co: start, + unconsidered.push(ScoredItem { cost: 0, - path: vec![start], + item: Crucible { + facing: Direction::South, + location: Coordinate { x: 0, y: 0 }, + steps_taken: 0, + }, }); - let mut global_min = 720; - let mut min_map = vec![vec![u32::MAX; grid[0].len()]; grid.len()]; - let mut longest_path = 0; - - while let Some(State { co, cost, path }) = heap.pop() { - if VIZ { - if path.len() > longest_path { - longest_path = path.len(); - println!("Path len: {longest_path}"); - } - } - - // Record cheapest for this position - if cost < min_map[co.0][co.1] { - min_map[co.0][co.1] = cost; + while let Some(current_square) = unconsidered.pop() { + let best_for_square = repeated_states + .get(¤t_square.item) + .unwrap_or(&i32::MAX); + if *best_for_square <= current_square.cost { + continue; } - // If this path is costlier than current min to get to this position, end the path - else { + repeated_states.insert(current_square.item, current_square.cost); + if current_square.item.location == goal && current_square.item.steps_taken >= min_move { + return current_square.cost; + } else if current_square.item.location == goal { continue; } - - // If this path is at finish, record cost and end the path - if co == end { - global_min = cost; - if VIZ { - println!( - "Found new min: {}, remaining paths to analyze: {}", - global_min, - heap.len() - ); + if current_square.item.steps_taken + 1 < max_move { + let next_square = current_square + .item + .location + .neighbour(current_square.item.facing); + if grid.contains_key(&next_square) { + unconsidered.push(ScoredItem { + cost: current_square.cost + grid.get(&next_square).unwrap(), + item: Crucible { + facing: current_square.item.facing, + location: next_square, + steps_taken: current_square.item.steps_taken + 1, + }, + }); } - continue; } - - // Record next potential steps - for state in possible_steps(co, &path, grid.len(), grid[0].len()).map(|next| { - let mut npath = path.to_vec(); - npath.push(next); - let ncost = cost + grid[next.0][next.1]; - State { - co: next, - cost: ncost, - path: npath, + let forks = match current_square.item.facing { + Direction::North | Direction::South => [Direction::East, Direction::West], + Direction::East | Direction::West => [Direction::North, Direction::South], + _ => unimplemented!(), + }; + if current_square.item.steps_taken + 1 >= min_move { + for next_direction in forks { + let next_square = current_square.item.location.neighbour(next_direction); + if grid.contains_key(&next_square) { + unconsidered.push(ScoredItem { + cost: current_square.cost + grid.get(&next_square).unwrap(), + item: Crucible { + facing: next_direction, + location: next_square, + steps_taken: 0, + }, + }); + } } - }) { - heap.push(state); } } - - global_min - grid[start.0][start.1] + 0 } -fn main() -> anyhow::Result<()> { - let lines = INPUT.lines(); - - let grid = lines - .into_iter() - .map(|line| line.chars().map(|c| c.to_digit(10).unwrap()).collect_vec()) - .collect_vec(); - - let min = dijkstra((0, 0), (grid.len() - 1, grid[0].len() - 1), &grid) as i64; - - println!("{min}"); - - Ok(()) +#[cfg(test)] +mod tests { + + use super::*; + const DATA: &str = "2413432311323 +3215453535623 +3255245654254 +3446585845452 +4546657867536 +1438598798454 +4457876987766 +3637877979653 +4654967986887 +4564679986453 +1224686865563 +2546548887735 +4322674655533"; + + #[test] + fn test_checksum() { + let grid: HashMap, i32> = parse_number_grid(DATA); + assert_eq!(part1(&grid, 0, 3), 102); + assert_eq!(part1(&grid, 4, 10), 94); + } } diff --git a/examples/day17_old.rs b/examples/day17_old.rs new file mode 100644 index 0000000..78accd1 --- /dev/null +++ b/examples/day17_old.rs @@ -0,0 +1,211 @@ +use itertools::Itertools; +use std::{collections::*, iter}; + +const INPUT: &str = include_str!("inputs/day17.txt"); +const TEST_INPUT: &str = include_str!("inputs/day17_test.txt"); +const CUSTOM_INPUT: &str = include_str!("inputs/day17_custom.txt"); + +type Co = (usize, usize); + +fn try_add(co: &Co, offset: (isize, isize), rows: usize, cols: usize) -> Option { + let row = co.0.checked_add_signed(offset.0); + let col = co.1.checked_add_signed(offset.1); + row.zip(col).filter(|&(row, col)| row < rows && col < cols) +} + +fn possible_steps( + to: Co, + path: &[Co], + rows: usize, + cols: usize, +) -> impl Iterator + '_ { + [(-1, 0), (1, 0), (0, -1), (0, 1)] + .into_iter() + // Avoid walls + .filter_map(move |offset| try_add(&to, offset, rows, cols)) + // Do not go backwards + .filter(|next| { + if path.len() <= 1 { + true + } else { + *next != path[path.len() - 2] + } + }) + // Do not revisit nodes in a given path (cycling paths are always longer than no cycles) + .filter(|next| !path.contains(next)) + // Avoid going more than 3 times in the same direction (note the 4th element from arriving on a given col or row) + .filter(|next| { + if path.len() <= 3 { + return true; + } + + let (rows, cols): (Vec, Vec) = path[path.len() - 4..] + .iter() + .chain(iter::once(next)) + .map(|&(r, c)| (r, c)) + .unzip(); + + !rows.windows(2).all(|w| w[0] == w[1]) && !cols.windows(2).all(|w| w[0] == w[1]) + }) +} + +const VIZ: bool = true; + +fn dfs(co: Co, end: Co, cost: u32, global_min: &mut u32, path: &[Co], grid: &[Vec], d: usize) { + if VIZ { + for (y, row) in grid.iter().enumerate() { + for (x, c) in row.iter().enumerate() { + if co == (y, x) { + print!("*"); + } else { + print!("{c}"); + } + } + println!(); + } + } + + // If this path is costlier than global min, end the path + if cost > *global_min { + if VIZ { + println!("DIED"); + println!(); + } + return; + } + + // If this path is at finish and its still cheaper than global min, record cost and end the path + if co == end { + *global_min = cost; + if VIZ { + println!("FINISHED"); + println!(); + } + return; + } + + /*if d >= 10 { + if VIZ { + println!("MAXED"); + println!(); + } + return; + }*/ + + if VIZ { + println!(); + } + + // Find potential next steps + let mut potential_next = possible_steps(co, path, grid.len(), grid[0].len()).collect_vec(); + + // Optimize order + potential_next.sort_by(|a, b| grid[a.0][a.1].cmp(&grid[b.0][b.1])); + + potential_next.into_iter().for_each(|next| { + let mut npath = path.to_vec(); + npath.push(next); + let ncost = cost + grid[next.0][next.1]; + dfs(next, end, ncost, global_min, &npath, grid, d + 1) + }); +} + +fn init_dfs(start: Co, end: Co, grid: &[Vec]) -> u32 { + let mut min = u32::MAX; + dfs(start, end, 0, &mut min, &vec![start], grid, 0); + min +} + +#[derive(Clone, Eq, PartialEq)] +struct State { + co: Co, + cost: u32, + path: Vec, +} + +impl Ord for State { + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + self.cost.cmp(&other.cost) + } +} + +impl PartialOrd for State { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + +fn dijkstra(start: Co, end: Co, grid: &[Vec]) -> u32 { + let mut heap = BinaryHeap::new(); + heap.push(State { + co: start, + cost: 0, + path: vec![start], + }); + + let mut global_min = 720; + let mut min_map = vec![vec![u32::MAX; grid[0].len()]; grid.len()]; + let mut longest_path = 0; + + while let Some(State { co, cost, path }) = heap.pop() { + if VIZ { + if path.len() > longest_path { + longest_path = path.len(); + println!("Path len: {longest_path}"); + } + } + + // Record cheapest for this position + if cost < min_map[co.0][co.1] { + min_map[co.0][co.1] = cost; + } + // If this path is costlier than current min to get to this position, end the path + else { + continue; + } + + // If this path is at finish, record cost and end the path + if co == end { + global_min = cost; + if VIZ { + println!( + "Found new min: {}, remaining paths to analyze: {}", + global_min, + heap.len() + ); + } + continue; + } + + // Record next potential steps + for state in possible_steps(co, &path, grid.len(), grid[0].len()).map(|next| { + let mut npath = path.to_vec(); + npath.push(next); + let ncost = cost + grid[next.0][next.1]; + State { + co: next, + cost: ncost, + path: npath, + } + }) { + heap.push(state); + } + } + + global_min - grid[start.0][start.1] +} + +fn main() -> anyhow::Result<()> { + let lines = INPUT.lines(); + + let grid = lines + .into_iter() + .map(|line| line.chars().map(|c| c.to_digit(10).unwrap()).collect_vec()) + .collect_vec(); + + let min = dijkstra((0, 0), (grid.len() - 1, grid[0].len() - 1), &grid) as i64; + + println!("{min}"); + + Ok(()) +} diff --git a/examples/day24.rs b/examples/day24.rs new file mode 100644 index 0000000..5d13fbc --- /dev/null +++ b/examples/day24.rs @@ -0,0 +1,177 @@ +use itertools::Itertools; + +const INPUT: &str = include_str!("inputs/day24.txt"); +const _TEST_INPUT: &str = include_str!("inputs/day24_test.txt"); + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +struct V2((i64, i64)); + +#[derive(Debug)] +struct F2((f64, f64)); + +impl std::ops::Sub for V2 { + type Output = V2; + + fn sub(self, rhs: Self) -> Self::Output { + V2((self.0 .0 - rhs.0 .0, self.0 .1 - rhs.0 .1)) + } +} + +impl V2 { + fn as_tuple(&self) -> (i64, i64) { + self.0 + } +} + +impl From for F2 { + fn from(value: V2) -> Self { + F2((value.0 .0 as f64, value.0 .1 as f64)) + } +} + +impl std::ops::Mul for F2 { + type Output = F2; + + fn mul(self, rhs: f64) -> Self::Output { + F2((self.0 .0 * rhs, self.0 .1 * rhs)) + } +} + +impl std::ops::Add for F2 { + type Output = F2; + + fn add(self, rhs: Self) -> Self::Output { + F2((self.0 .0 + rhs.0 .0, self.0 .1 + rhs.0 .1)) + } +} + +impl std::ops::Mul for V2 { + type Output = F2; + + fn mul(self, rhs: f64) -> Self::Output { + F2::from(self) * rhs + } +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +struct V3((i64, i64, i64)); + +impl V3 { + fn trunc(self) -> V2 { + V2((self.0 .0, self.0 .1)) + } +} + +enum Intersect { + Future((f64, f64)), + Never, + Past((f64, f64)), +} + +fn future_intersect(x0: V2, v0: V2, x1: V2, v1: V2) -> Intersect { + let (x0_x, x0_y) = x0.as_tuple(); + let (v0_x, v0_y) = v0.as_tuple(); + let (x1_x, x1_y) = x1.as_tuple(); + let (v1_x, v1_y) = v1.as_tuple(); + + // Check for parallel + let dvx = v0_x - v1_x; + let dvy = v0_y - v1_y; + if dvx == dvy { + return Intersect::Never; + } + + // Calculate time of intersection along each axis + let tx = (x1_x - x0_x) as f64 / dvx as f64; + let ty = (x1_y - x0_y) as f64 / dvy as f64; + + // Point of intersect + let px = x0_x as f64 + tx * (v0_x as f64); + let py = x0_y as f64 + ty * (v0_y as f64); + + // Intersection happened in the past + if tx < 0. || ty < 0. { + return Intersect::Past((px, py)); + } + + Intersect::Future((px, py)) +} + +fn main() -> anyhow::Result<()> { + let lines = _TEST_INPUT.lines(); + + let hailstones = lines + .map(|line| { + let (pos, vel) = line.split_once('@').unwrap(); + + let mut pos_it = pos.split(',').map(|s| s.trim().parse::().unwrap()); + let (x, y, z) = ( + pos_it.next().unwrap(), + pos_it.next().unwrap(), + pos_it.next().unwrap(), + ); + let mut vel_it = vel.split(',').map(|s| s.trim().parse::().unwrap()); + let (vx, vy, vz) = ( + vel_it.next().unwrap(), + vel_it.next().unwrap(), + vel_it.next().unwrap(), + ); + + (V3((x, y, z)), V3((vx, vy, vz))) + }) + .collect_vec(); + + let min: f64 = 7f64; //200000000000000f64; + let max: f64 = 27f64; //400000000000000f64; + + let hailstones_2d = hailstones + .iter() + .map(|(x0, v0)| (x0.trunc(), v0.trunc())) + .collect_vec(); + + let mut count = 0; + for idx0 in 0..hailstones_2d.len() { + let (x0, v0) = hailstones_2d[idx0]; + for idx1 in idx0 + 1..hailstones_2d.len() { + let (x1, v1) = hailstones_2d[idx1]; + match future_intersect(x0, v0, x1, v1) { + Intersect::Future((px, py)) => { + if px >= min && px <= max && py >= min && py <= max { + println!( + "Hailstones {:?} and {:?} will cross inside the test area (at {:?})", + x0, + x1, + (px, py) + ); + count += 1; + } else { + println!( + "Hailstones {:?} and {:?} will cross outside the test area (at {:?})", + x0, + x1, + (px, py) + ); + } + } + Intersect::Never => { + println!( + "Hailstones' {:?} and {:?} paths are parallel; they never intersect", + x0, x1, + ); + } + Intersect::Past((px, py)) => { + println!( + "Hailstones {:?} and {:?} crossed in the past at {:?}", + x0, + x1, + (px, py) + ); + } + } + } + } + + println!("{count}"); + + Ok(()) +} diff --git a/examples/inputs/day24.txt b/examples/inputs/day24.txt new file mode 100644 index 0000000..f2aabd2 --- /dev/null +++ b/examples/inputs/day24.txt @@ -0,0 +1,300 @@ +346929738756520, 180308062329517, 348158644025623 @ 6, -5, -22 +254810664927620, 353739895010289, 244141919277765 @ -144, 403, -76 +295870756794909, 404627177923603, 198720163538165 @ -23, -185, 145 +245963903877515, 463230951802017, 204063276689103 @ -175, -493, 282 +240883930774627, 293767063383987, 385416738115181 @ 85, 41, -232 +258783790598300, 416085987737022, 244244689804488 @ -106, -108, -37 +316881219411455, 207115465839939, 3231271691721 @ 36, -33, 311 +159692118609179, 278631004484055, 273317916049077 @ 194, -83, 45 +372719112455483, 164426621521265, 78323731342860 @ -55, 75, 273 +288690854255051, 303366864842388, 441853886465373 @ 45, -90, -168 +231474036233045, 203197598170947, 325158536216283 @ 116, 10, -16 +307983644394617, 107725860376215, 326740994553027 @ -16, 288, -72 +347506682121503, 194283076183827, 291055039661129 @ -10, 11, 25 +291356463389145, 224489891532087, 277427773123203 @ 27, 50, 21 +271941427915733, 503433763356759, 213162447327457 @ -121, -547, 136 +242916393274521, 370793247991631, 228014536745307 @ -45, 247, 48 +195691614411751, 344202548829805, 373444276238427 @ 168, -98, -150 +448108397653615, 342984318211037, 372702655692203 @ -171, -129, -98 +271056836136539, 405347750286045, 246867310344900 @ 53, -205, 63 +274231496615407, 283191180514355, 255949392007171 @ 30, 27, 38 +268173892092665, 387613124026942, 256019132096528 @ -157, 54, -103 +145730094834998, 142101281327937, 172439903235819 @ 288, 391, 206 +305847991862255, 276335347676657, 503944348756392 @ 41, -89, -189 +265457297226648, 144055141922672, 446464604425555 @ 54, 226, -266 +443126534652569, 178726379965761, 343056914693889 @ -157, 78, -55 +317507350884249, 298357353125303, 316323674823843 @ -71, 33, -93 +317102853816209, 234699930026565, 480571101005673 @ 15, -16, -203 +283815679400309, 265670286941517, 179687664955092 @ 23, 31, 169 +354277266977008, 90413312230484, 298759791596563 @ -8, 100, 22 +188130119114625, 305334499796621, 197145830115250 @ 171, -77, 133 +217619375871548, 283307600493768, 172874363222667 @ 134, 622, 366 +327036301988501, 284507486595513, 301783526443797 @ -55, 10, -37 +291294719486768, 281439705434034, 111406071781614 @ -28, 90, 339 +393431484027881, 192044228859519, 311300408945955 @ -85, 49, -10 +327212822886707, 176259962509678, 417753026665839 @ 5, 48, -126 +253019932261409, 87556034477403, 425707031938091 @ 95, 107, -110 +343802345556755, 200045103898485, 358872039028185 @ -124, 232, -179 +226423296932161, 287474657895527, 236227429420451 @ 108, 171, 58 +423624248192453, 222403770309101, 230490512494973 @ -73, -41, 92 +259972516151316, 417326315176952, 297367106203031 @ -132, -104, -382 +357044388564161, 168284250644379, 392663023445865 @ -73, 143, -151 +286242181450641, 310282933434825, 298355297631705 @ -21, 35, -72 +253948061505860, 369630604078812, 239455106291328 @ -10, 26, 27 +239247112781688, 473045134379203, 264130376870531 @ -116, -623, -410 +266954546929617, 409841545933499, 190223858265703 @ -71, -126, 227 +294916260345622, 222459326307321, 289284460090659 @ 24, 47, 6 +219407383690143, 427730064131051, 234951115565415 @ 114, -65, -96 +301401145552568, 36984984825456, 197971574438235 @ 42, 174, 126 +319901756793401, 364249214426947, 483252487665531 @ -13, -149, -270 +280122340920530, 338555287223541, 253750371602817 @ -14, -17, 24 +407171712463280, 363153037705467, 353967780171198 @ -128, -151, -81 +269729137439913, 248583309313707, 272666749250639 @ 55, 26, 25 +270357777166223, 506821092648093, 426574947795905 @ 32, -382, -289 +275826795507555, 257671822789787, 306324926273288 @ -63, 361, -187 +285012671761982, 521652273856721, 216367020466425 @ 32, -377, 108 +327965141155649, 178050422463823, 346598709787519 @ 17, 15, -29 +271104057789300, 199387239172395, 229082348529192 @ 76, -7, 93 +237639276866838, 421292181214357, 238483621512125 @ -48, -69, -64 +268609557946865, 417945112890887, 234352501966459 @ 26, -209, 73 +460084443910591, 444183291889519, 400893505677911 @ -306, -263, -224 +245379946602488, 419420052950156, 246560981116374 @ -172, -8, -189 +311593654255928, 231552467174470, 286506183154830 @ 8, 18, 15 +259640165565909, 216219162731006, 373577535562947 @ 79, 24, -90 +376825234704953, 155953288596591, 340461757659663 @ -21, 15, -13 +250701059815145, 381007974543967, 245801016194043 @ -19, 22, -15 +307889037742285, 255168611968841, 274256349658287 @ 21, -30, 36 +259743178472647, 195862295848667, 385479856860614 @ 33, 321, -287 +356184986451331, 470259784254945, 338726147578791 @ -30, -292, -36 +544879725653049, 240618134651495, 269806636609235 @ -213, -47, 50 +226448920127645, 384358468265112, 302896930125678 @ 111, -120, -97 +297191152126465, 204874378856127, 383280058614266 @ -149, 581, -475 +238039746567361, 367609679835106, 236093408040181 @ 27, 130, 20 +325134771317770, 239144052305622, 444638567349793 @ 6, -22, -160 +207437495918169, 362557904124171, 262637210676171 @ 163, -22, -24 +188566572519873, 176688051987113, 158590319064474 @ 187, 243, 219 +421199238751382, 509889592963725, 313629062398536 @ -150, -353, -27 +329474824303769, 137105704471351, 308668584420995 @ 20, 45, 14 +384284947399523, 94442398625779, 247151524648919 @ -43, 105, 74 +224628872740967, 397608510897879, 304826638045071 @ 110, -115, -172 +224802125565602, 401888871179499, 218504785717512 @ 72, 97, 119 +261639052395764, 292929865317270, 278546258379453 @ -56, 382, -148 +464503384688289, 477737756450951, 527338778199907 @ -296, -321, -430 +225304070101391, 36324730187453, 137464093593680 @ 113, 763, 311 +391971233533925, 172560926934078, 298633929998754 @ -49, 20, 21 +194646872355977, 342529410718314, 226296913665495 @ 179, -56, 90 +301831680914049, 286165790187783, 318516958643987 @ 15, -43, -34 +229272198230105, 406617091656483, 264313273687395 @ -29, 250, -530 +206759346436820, 314394022225212, 216618616528428 @ 152, -24, 109 +210109523618201, 252287712315219, 327082928096211 @ 147, 118, -110 +359756323365687, 458267774674135, 179671475220083 @ -8, -275, 142 +256636215052467, 382174219516492, 22836371057063 @ 57, -144, 482 +303600101392345, 304099062287287, 271877170686403 @ -221, 309, -110 +192427419113801, 270646375181823, 205521109713267 @ 169, -6, 124 +317580015441782, 303321432596532, 160901766712155 @ -16, -54, 190 +312210109792613, 308036264286237, 276372788042127 @ -27, -34, 8 +274808900596306, 313220586507812, 302025327543365 @ -12, 66, -104 +183695853615473, 47549844076063, 245309240110855 @ 167, 153, 76 +189960720081275, 156846337036957, 355773594863379 @ 176, 196, -114 +315898949803573, 42044780661455, 267046640179187 @ 22, 187, 50 +418323980502335, 178070634118737, 292119373352883 @ -70, 6, 30 +347391101811593, 215813841268803, 243752174696145 @ -13, -7, 76 +38776347800773, 67432306786607, 58776619731659 @ 313, 121, 266 +290017976156156, 59611625019226, 197353083885397 @ 50, 172, 128 +229601257408320, 129680370628487, 140327485196978 @ 114, 205, 221 +220146734490753, 391298290057083, 344611334445703 @ 123, -55, -398 +174825913754515, 276681616157484, 157894323921694 @ 201, 8, 203 +483401510893445, 357491162194512, 463859876172903 @ -161, -166, -166 +245206442460985, 141656245486967, 217620774820323 @ 73, 385, 108 +291464705325145, 277556116295287, 297389023917603 @ -9, 55, -45 +261983560452785, 360894647865153, 280311392609911 @ 11, -37, -62 +238119753223441, 384199740050288, 223297579256688 @ 27, 42, 87 +342600534427159, 197167142655207, 329559491968412 @ 9, -19, -5 +252758590023093, 359232287922907, 176041820643661 @ 39, -39, 220 +313253294659799, 251781593278779, 261074695981700 @ -7, 17, 43 +248049581038085, 423970640867607, 261396846241653 @ -55, -147, -153 +310310365543019, 281706767922567, 377342034050858 @ -7, -19, -133 +274524314300875, 363058350994865, 422526291132292 @ 61, -161, -149 +212983922822636, 358147301791551, 244530045292062 @ 172, 405, -89 +263592759586169, 439129308139773, 339680624336391 @ 83, -256, -24 +233868210908012, 409660495064857, 233230663284208 @ -10, 31, -13 +269259823873537, 396788847877277, 259990192662409 @ -33, -114, -25 +216345390855161, 383912500300599, 205451058893835 @ 135, -131, 135 +286337439756209, 339702196645491, 252072691186197 @ -37, -7, 24 +275611813821911, 373676685727101, 212650030133112 @ -187, 119, 145 +245406568832581, 362174337037453, 90022762517045 @ 103, -177, 236 +338003345512565, 108786412025047, 403159101348503 @ -10, 133, -113 +237607008125125, 409880740768920, 194303698368487 @ -9, -28, 290 +320517997573421, 219675501957427, 303132532685123 @ 32, -44, 22 +190493006619409, 145810007452413, 300903507010435 @ 175, 212, -26 +409372170846134, 393434813069206, 367775154646167 @ -196, -176, -150 +126706795930865, 185138771407284, 279863075454285 @ 251, 78, 24 +259975694120207, 310184989013831, 170094651355847 @ -100, 469, 380 +241669096325265, 333749292411567, 208426046916243 @ -116, 878, 228 +276541809961373, 227328593043837, 345768644614869 @ 63, -9, -44 +317215535236435, 357611609562111, 227448490908701 @ -24, -127, 91 +297409993247840, 72133954474177, 293703979805093 @ 38, 175, 16 +267425274950468, 178987597651560, 327276547274805 @ 60, 120, -52 +225123145589429, 340048662295203, 270745781295801 @ 109, 63, -57 +264716260516415, 373685852434491, 193519345153847 @ 86, -193, 128 +219211205263007, 383081930275815, 239521924631696 @ 125, 77, -7 +183533214122180, 37154332503678, 273932305391058 @ 186, 384, 17 +211600294479339, 354700894876755, 262056383423015 @ 154, 47, -44 +245726548134265, 396188140159227, 224602979518873 @ 19, -73, 85 +296017416223129, 262019476718071, 245168206357635 @ -20, 90, 54 +393308924026495, 467372206762237, 509882972456228 @ -131, -297, -331 +237149300135070, 357245834641037, 243498444015758 @ 66, 31, 23 +262792373213470, 447756982297962, 301066314564528 @ -216, -304, -525 +236201706595106, 364333372414073, 200189749005974 @ 98, -117, 139 +250325589368367, 340065027343661, 256909487155833 @ 12, 118, -33 +322682840322333, 321922443943079, 162465267997475 @ 30, -143, 158 +252845275150105, 166109785775702, 254020415404633 @ 67, 250, 40 +290539383225193, 485118332097731, 263568173368847 @ 27, -321, 40 +314213388853217, 273874838945961, 298815518006850 @ -5, -21, -9 +249010320438313, 390481614169435, 243765169904195 @ -17, -12, -10 +264546133397077, 347915307439685, 295405452829817 @ -195, 402, -425 +287479772707633, 414798176994951, 177572614230027 @ -68, -181, 225 +142206521256717, 242389904441473, 65280407690499 @ 225, -12, 294 +226068175168529, 422152119716711, 244053383631523 @ 44, -41, -158 +239770615926105, 416846132500671, 222985020485767 @ -29, -73, 83 +267385178551504, 361873106344791, 203732099641183 @ 72, -163, 122 +324949088506511, 219103967683671, 331077336923604 @ -7, 29, -41 +242726897402074, 352269867368416, 97011163496955 @ 88, -102, 318 +256506861588105, 319883885561847, 277548233971123 @ 82, -103, 29 +226382902069970, 184416705088008, 269758215192153 @ 106, 524, -48 +301649720323014, 186334340182818, 22452578721493 @ 34, 38, 332 +248841817400819, 493995156705969, 184845194231523 @ 62, -376, 182 +227803699895655, 360958880352603, 172198482302653 @ 121, -175, 152 +246330580009595, 71604038045112, 331445314710153 @ 97, 188, -32 +241861496905749, 413048278354139, 254340624153939 @ 22, -126, -54 +237008737207956, 395872601195470, 221538466193469 @ 30, -12, 96 +253638827421089, 296127490712211, 158251668973779 @ -95, 670, 498 +297603380783105, 275137048217571, 302510571012695 @ 11, -7, -22 +244153076889227, 389279503840137, 249339330263060 @ -91, 191, -145 +258161109760168, 348985357786464, 238697530128240 @ -20, 92, 33 +152456636067995, 79288225862379, 237063482792721 @ 206, 155, 83 +313609592292443, 195836729561268, 208085299426260 @ -47, 200, 125 +264859523645520, 380468739503827, 225735319294618 @ -194, 169, 65 +252929779231061, 351140791527735, 284282216420763 @ 82, -131, 12 +320818475035442, 126733705515175, 293005764735413 @ 32, 45, 32 +271640824188383, 404397875087375, 280225620114867 @ -148, -63, -210 +294926613177179, 435792225326613, 421159908513108 @ -43, -245, -353 +163601335284041, 69153708744543, 235573806748843 @ 203, 233, 82 +323711917742135, 142584270844479, 311897348352861 @ -34, 209, -41 +210398743076103, 364131519667754, 41461274599411 @ 165, 82, 886 +361669985691089, 276988494443175, 347544013623303 @ -123, 33, -123 +228622494255699, 447141518124271, 191028714048703 @ -47, -347, 602 +230946320766439, 371732249571627, 233745668476439 @ 60, 131, 28 +387047622197732, 263650615046919, 530761078904505 @ -66, -51, -260 +204318774492610, 285348414109612, 180353018703128 @ 150, -44, 157 +316938644707683, 318395158499001, 441571684647865 @ -116, 50, -451 +404386231732889, 435091191164301, 263801046680007 @ -221, -246, 20 +214388183865873, 325524779011064, 304333898756005 @ 139, -12, -76 +253443075382360, 144662659438177, 166047542561593 @ 70, 255, 196 +289819947955942, 327933608612441, 306499816377535 @ -192, 255, -286 +348636024502875, 135428003663637, 149678516981253 @ -35, 131, 192 +301517904510352, 263200578126125, 173215853076640 @ 48, -81, 149 +246737341196903, 405819322564735, 227502077298049 @ -103, 37, 44 +237654890585495, 426112750459429, 256419924673156 @ -19, -137, -175 +254430014927285, 403866678554647, 232142472062723 @ 32, -155, 70 +244272028800102, 414522292160103, 221371725024508 @ -6, -115, 97 +350727625829385, 226545920886697, 352114534069073 @ -21, -12, -49 +168281220814693, 285093164334117, 41821753037391 @ 193, -64, 324 +237224474564528, 401040727498329, 236160314682033 @ 22, -25, 12 +230723550294953, 424917873359919, 236273160877675 @ 89, -202, 49 +190058048682023, 289491655863888, 260489524234914 @ 185, 34, 25 +273027022338905, 435453377172003, 291060457086219 @ -29, -240, -104 +323863826623077, 261288486906273, 291093020969518 @ -41, 35, -13 +381311469178660, 238264875168207, 343018349522353 @ -42, -43, -28 +239959422048956, 413611453698967, 337393091048823 @ 8, -99, -558 +390672856277883, 254260210150227, 323211560142793 @ -62, -49, -13 +220405422230777, 424143081174633, 261123292479783 @ 115, -132, -188 +317814328653385, 237592338375527, 281224961588163 @ 13, -17, 30 +372248877968761, 192983238830927, 272094983188123 @ -33, 6, 47 +281315993876090, 397199825306607, 213490174830593 @ -106, -91, 128 +256373650644817, 360540918952599, 248632791890587 @ 24, -31, 23 +275575031534705, 249264387231127, 283113672563803 @ 44, 33, 7 +449385877224908, 326078515360436, 524284356662575 @ -286, -50, -446 +313536732056795, 386014324064559, 459921162471213 @ -94, -127, -463 +213450437840781, 300692433433167, 335613357460107 @ 144, 131, -216 +274859796494865, 297125782560275, 254954260763087 @ 21, 22, 35 +317873726016779, 246497638238614, 314593121231524 @ 5, -12, -17 +195410532618745, 308659034016263, 165820830551043 @ 181, 34, 222 +276636406073385, 266538617015367, 211930157612523 @ 69, -73, 111 +413449598702423, 247670250781983, 316576712343081 @ -66, -63, 5 +303751369571870, 396373289798112, 294544878432753 @ -190, -88, -176 +449363367354400, 126776874403421, 281758479642638 @ -114, 75, 37 +306959131227953, 483517257215199, 372762778195947 @ -87, -361, -272 +234965559228377, 415241411419959, 228112989082755 @ -35, 5, 26 +315096640041344, 265031848270326, 175734010646799 @ -138, 232, 226 +224931637234775, 426167579929617, 113948071865798 @ 113, -217, 385 +255242786323001, 329174345696275, 252480177927766 @ 35, 33, 19 +238829928250448, 337419222410424, 304298097895563 @ 62, 90, -178 +276542932074572, 337033291374879, 447779154818487 @ -96, 149, -782 +224277906155665, 322106728847627, 328044360034623 @ 109, 172, -285 +342471593470058, 300168184358787, 318733865717811 @ -132, 41, -106 +279397154254970, 343570156775787, 328761990688278 @ 14, -71, -105 +237311503150804, 469911741188278, 236430921483672 @ 70, -348, 51 +163553711268733, 262718939353865, 314198487467041 @ 223, 43, -56 +273246200444207, 382207087452219, 239932772430915 @ -140, 35, 6 +405722309789197, 438877185173229, 180226720634049 @ -51, -256, 141 +313470221835370, 291331685030307, 212049985689993 @ -74, 65, 120 +431219618065897, 132622196749649, 518497804844082 @ -77, 43, -189 +452480016925861, 152909739410548, 413444920324842 @ -113, 42, -99 +88829548759257, 164111232273937, 114327617757873 @ 259, 16, 207 +230233245111083, 418214329529835, 228075143090871 @ 8, -17, 24 +304509308039540, 238841592710834, 317459283714085 @ 26, -12, -16 +242662932864281, 350618929108887, 251155289406435 @ 17, 166, -41 +348524426436457, 314737872125720, 303150209660151 @ -77, -56, -30 +425963677808745, 155199322587279, 227691859476209 @ -69, 17, 95 +258143591224361, 370459141004643, 458784506326683 @ 27, -73, -518 +276015069416403, 351412572800031, 270368426249345 @ -30, -7, -37 +345732335893709, 195001246917149, 325093740754435 @ -25, 43, -26 +362711363000271, 283081460148089, 264620481268225 @ -111, 7, 28 +293862466025198, 319934287436242, 184015179916795 @ -52, 36, 190 +300201936571798, 521140877272688, 289783914924793 @ -212, -590, -188 +409384133843569, 319271940577303, 279156613846323 @ -162, -71, 12 +235905846628205, 279098252472803, 382106263847083 @ 41, 567, -718 +377802732051335, 221963240519457, 147348254385723 @ -70, 18, 194 +223147935266293, 411221430298519, 224752800223807 @ 70, 117, 49 +228409269579218, 444626185420180, 166513325788745 @ 104, -266, 244 +151123821599091, 123864886643510, 238126296605255 @ 237, 244, 74 +307093987146275, 379714843167696, 266419236444753 @ -159, -56, -48 +208049377700500, 221098255631227, 263970672168443 @ 144, 25, 46 +303054635830541, 294856337954709, 268680935068161 @ -15, -6, 19 +229314585617959, 418862230435258, 267542619146805 @ 33, -56, -312 +293669872879595, 367896946991017, 201720949773263 @ 26, -156, 128 +255686713031885, 351903932376711, 264378989343327 @ 26, -7, -21 +266607574758005, 401000634407851, 219398762340027 @ -154, -18, 108 +343627019798124, 246175852136572, 512909523569205 @ -26, -14, -264 +292437319488810, 266766846992357, 303356561851098 @ -92, 267, -147 +303854432104229, 234294141498451, 294533122458627 @ 20, 10, 6 +215546399507603, 116183320507851, 372858484485153 @ 134, 115, -73 +248136881680325, 391007587950681, 268382285064291 @ -49, 47, -186 +234782346846530, 494355549983967, 247921721741640 @ -34, -779, -171 +363192222650684, 221986589921001, 259353636719643 @ -18, -33, 62 +276155580985958, 336211596217428, 284858638982773 @ -22, 20, -68 +282174699854010, 305188524637692, 261406770410318 @ -8, 38, 13 +320511755321145, 244634023349335, 257265475561443 @ 6, -18, 57 +66971777104821, 241669016746231, 158787992263555 @ 288, -51, 166 +294368676651785, 314665166754177, 228212823323973 @ -45, 35, 84 +338828518386317, 142617268061718, 320976106719513 @ -25, 128, -28 +319776438858095, 306673384812765, 385908913297893 @ -44, -26, -183 +358737002431245, 388182760881127, 258313482452743 @ -99, -171, 40 +267323686632791, 370215962843955, 256959554673048 @ -91, 65, -63 +231524131093292, 400994267551944, 231873985843329 @ 40, 20, 24 +308437363113215, 368126339780840, 293103849593885 @ -259, 60, -212 +190786479783439, 466089361087, 305628756672062 @ 193, 741, -91 +285594319782029, 139377422186787, 286124291710731 @ 53, 91, 26 +304729929268880, 343354040465328, 292686079957347 @ 16, -128, 6 +157641242982995, 234477187081287, 143569944431203 @ 194, -43, 182 +271635899390446, 401642527313401, 108206266391555 @ 70, -213, 230 +268390077989593, 388991475585177, 259268813203737 @ -125, 11, -96 +558756189530084, 451743170877306, 472294744774308 @ -322, -272, -233 +220980725636071, 407309980480139, 269989001290617 @ 124, -173, -21 +377742004992795, 290286641421687, 353930686655128 @ -71, -67, -67 +358195621698265, 230164474119143, 317568672131355 @ -29, -17, -9 +230545899424788, 422728105615127, 213323684027524 @ 28, -99, 161 +283957679948759, 183838154793909, 368886062272691 @ 53, 47, -74 +328390183181243, 361677503224065, 266007888635046 @ -31, -141, 35 +289605297584183, 215606437887927, 390190548172323 @ 30, 61, -138 diff --git a/examples/inputs/day24_test.txt b/examples/inputs/day24_test.txt new file mode 100644 index 0000000..35963dc --- /dev/null +++ b/examples/inputs/day24_test.txt @@ -0,0 +1,5 @@ +19, 13, 30 @ -2, 1, -2 +18, 19, 22 @ -1, -1, -2 +20, 25, 34 @ -2, -2, -4 +12, 31, 28 @ -1, -2, -1 +20, 19, 15 @ 1, -5, -3