From b60591ea38d5708d6914a03d21f0c5c4ded567d0 Mon Sep 17 00:00:00 2001 From: Connor Johnstone Date: Sat, 9 Dec 2023 14:00:10 -0700 Subject: [PATCH] Not working for some reason --- day_09/Cargo.lock | 738 ++++++++++++++++++++++++++++++++++++++++ day_09/Cargo.toml | 25 ++ day_09/benches/part1.rs | 11 + day_09/benches/part2.rs | 11 + day_09/input.txt | 200 +++++++++++ day_09/src/lib.rs | 55 +++ day_09/src/main.rs | 28 ++ 7 files changed, 1068 insertions(+) create mode 100644 day_09/Cargo.lock create mode 100644 day_09/Cargo.toml create mode 100644 day_09/benches/part1.rs create mode 100644 day_09/benches/part2.rs create mode 100644 day_09/input.txt create mode 100644 day_09/src/lib.rs create mode 100644 day_09/src/main.rs diff --git a/day_09/Cargo.lock b/day_09/Cargo.lock new file mode 100644 index 0000000..38ac713 --- /dev/null +++ b/day_09/Cargo.lock @@ -0,0 +1,738 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + +[[package]] +name = "anes" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bumpalo" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" + +[[package]] +name = "cast" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "ciborium" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926" +dependencies = [ + "ciborium-io", + "ciborium-ll", + "serde", +] + +[[package]] +name = "ciborium-io" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656" + +[[package]] +name = "ciborium-ll" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b" +dependencies = [ + "ciborium-io", + "half", +] + +[[package]] +name = "clap" +version = "3.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" +dependencies = [ + "bitflags", + "clap_lex", + "indexmap", + "textwrap", +] + +[[package]] +name = "clap_lex" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +dependencies = [ + "os_str_bytes", +] + +[[package]] +name = "criterion" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7c76e09c1aae2bc52b3d2f29e13c6572553b30c4aa1b8a49fd70de6412654cb" +dependencies = [ + "anes", + "atty", + "cast", + "ciborium", + "clap", + "criterion-plot", + "itertools", + "lazy_static", + "num-traits", + "oorandom", + "plotters", + "rayon", + "regex", + "serde", + "serde_derive", + "serde_json", + "tinytemplate", + "walkdir", +] + +[[package]] +name = "criterion-plot" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" +dependencies = [ + "cast", + "itertools", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +dependencies = [ + "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" +dependencies = [ + "autocfg", + "cfg-if", + "crossbeam-utils", + "memoffset", + "scopeguard", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "day_09" +version = "0.1.0" +dependencies = [ + "criterion", + "ndarray", + "nom", + "num", + "rayon", + "strum", + "strum_macros", +] + +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + +[[package]] +name = "half" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[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.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +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 = "itoa" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" + +[[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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.150" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" + +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + +[[package]] +name = "matrixmultiply" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7574c1cf36da4798ab73da5b215bbf444f50718207754cb522201d78d1cd0ff2" +dependencies = [ + "autocfg", + "rawpointer", +] + +[[package]] +name = "memchr" +version = "2.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" + +[[package]] +name = "memoffset" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "ndarray" +version = "0.15.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb12d4e967ec485a5f71c6311fe28158e9d6f4bc4a447b474184d0f91a8fa32" +dependencies = [ + "matrixmultiply", + "num-complex", + "num-integer", + "num-traits", + "rawpointer", +] + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "num" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05180d69e3da0e530ba2a1dae5110317e49e3b7f3d41be227dc5f92e49ee7af" +dependencies = [ + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits", +] + +[[package]] +name = "num-bigint" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-complex" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ba157ca0885411de85d6ca030ba7e2a83a28636056c7c699b07c8b6f7383214" +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.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" + +[[package]] +name = "oorandom" +version = "11.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" + +[[package]] +name = "os_str_bytes" +version = "6.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1" + +[[package]] +name = "plotters" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" +dependencies = [ + "num-traits", + "plotters-backend", + "plotters-svg", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "plotters-backend" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" + +[[package]] +name = "plotters-svg" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" +dependencies = [ + "plotters-backend", +] + +[[package]] +name = "proc-macro2" +version = "1.0.70" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rawpointer" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" + +[[package]] +name = "rayon" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "regex" +version = "1.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" + +[[package]] +name = "rustversion" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" + +[[package]] +name = "ryu" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "serde" +version = "1.0.193" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.193" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "strum" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" + +[[package]] +name = "strum_macros" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn", +] + +[[package]] +name = "syn" +version = "2.0.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "textwrap" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" + +[[package]] +name = "tinytemplate" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "walkdir" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +dependencies = [ + "same-file", + "winapi-util", +] + +[[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-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 = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/day_09/Cargo.toml b/day_09/Cargo.toml new file mode 100644 index 0000000..d04f597 --- /dev/null +++ b/day_09/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "day_09" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +ndarray = "0.15.6" +nom = "7.1.3" +num = "0.4.1" +rayon = "1.8.0" +strum = "0.25.0" +strum_macros = "0.25.3" + +[dev-dependencies] +criterion = { version = "0.4", features = ["html_reports"] } + +[[bench]] +name = "part1" +harness = false + +[[bench]] +name = "part2" +harness = false diff --git a/day_09/benches/part1.rs b/day_09/benches/part1.rs new file mode 100644 index 0000000..603df37 --- /dev/null +++ b/day_09/benches/part1.rs @@ -0,0 +1,11 @@ +use criterion::{black_box, criterion_group, criterion_main, Criterion}; + +use day_09::prelude::*; + +fn criterion_benchmark(c: &mut Criterion) { + let input = include_str!("../input.txt"); + c.bench_function("part 1", |b| b.iter(|| part1(black_box(input)))); +} + +criterion_group!(benches, criterion_benchmark); +criterion_main!(benches); diff --git a/day_09/benches/part2.rs b/day_09/benches/part2.rs new file mode 100644 index 0000000..c448bd2 --- /dev/null +++ b/day_09/benches/part2.rs @@ -0,0 +1,11 @@ +use criterion::{black_box, criterion_group, criterion_main, Criterion}; + +use day_09::prelude::*; + +fn criterion_benchmark(c: &mut Criterion) { + let input = include_str!("../input.txt"); + c.bench_function("part 2", |b| b.iter(|| part2(black_box(input)))); +} + +criterion_group!(benches, criterion_benchmark); +criterion_main!(benches); diff --git a/day_09/input.txt b/day_09/input.txt new file mode 100644 index 0000000..d247625 --- /dev/null +++ b/day_09/input.txt @@ -0,0 +1,200 @@ +9 10 20 47 106 220 423 776 1406 2579 4829 9202 17771 34815 69626 143262 304678 668562 1501903 3416589 7785735 +1 -2 10 50 131 266 468 750 1125 1606 2206 2938 3815 4850 6056 7446 9033 10830 12850 15106 17611 +19 29 47 83 149 268 498 980 2026 4267 8881 17926 34847 65403 119791 218088 404153 779333 1579159 3337521 7219269 +10 16 41 95 186 325 535 868 1447 2564 4875 9734 19695 39179 75247 138335 242688 406072 648141 986585 1429880 +-4 3 31 101 237 473 883 1645 3150 6167 12075 23173 43079 77229 133487 222877 360448 566283 866663 1295397 1895329 +9 16 34 68 119 190 304 541 1101 2400 5206 10822 21323 39854 70996 121207 199345 317280 490602 739432 1089343 +7 19 31 43 55 67 79 91 103 115 127 139 151 163 175 187 199 211 223 235 247 +18 39 68 101 147 247 493 1042 2120 4011 7026 11447 17441 24939 33475 41980 48526 50015 41808 17289 -32641 +19 25 31 37 55 124 325 796 1747 3475 6379 10975 17911 27982 42145 61534 87475 121501 165367 221065 290839 +21 25 37 80 185 398 797 1519 2797 5007 8725 14794 24401 39164 61229 93377 139141 202933 290181 407476 562729 +22 50 92 154 262 480 947 1962 4159 8823 18402 37270 72795 136769 247271 431068 726724 1188696 1892864 2944186 4487508 +18 38 70 122 217 403 769 1469 2753 5007 8828 15229 26229 46435 86996 175010 375162 838183 1906602 4339181 9773011 +20 40 84 172 336 637 1201 2290 4451 8832 17823 36276 73685 147869 290902 558278 1042590 1893344 3344926 5755196 9657702 +5 14 22 26 15 -23 -67 10 574 2460 7349 18335 40685 82740 156942 281413 484087 815614 1386976 2468048 4722711 +-2 10 29 59 115 222 407 688 1072 1582 2341 3749 6797 13570 27999 56930 111586 209506 377053 652591 1090439 +2 9 31 75 153 283 490 807 1276 1949 2889 4171 5883 8127 11020 14695 19302 25009 32003 40491 50701 +10 28 56 99 164 274 507 1069 2422 5517 12235 26232 54546 110604 219762 429452 827968 1580228 2998352 5685247 10831054 +20 39 79 164 344 720 1484 2988 5881 11403 22016 42703 83499 164158 322335 627303 1202066 2257807 4145965 7434910 13020226 +15 21 38 73 132 224 371 638 1219 2661 6393 15869 38854 91704 206942 446042 920135 1822381 3477048 6411945 11462816 +6 22 39 56 79 119 193 348 752 1947 5454 15078 39503 97116 224480 490516 1019282 2025284 3866553 7122308 12703935 +15 26 42 71 130 256 518 1038 2038 3948 7657 15092 30502 63156 132738 279754 585196 1207392 2451021 4896657 9644293 +1 15 46 110 239 499 1023 2072 4142 8132 15583 29007 52374 91950 157926 267703 452367 768877 1321884 2300996 4041809 +12 18 23 27 30 32 33 33 32 30 27 23 18 12 5 -3 -12 -22 -33 -45 -58 +9 18 26 45 108 281 679 1488 3001 5693 10385 18582 33132 59484 108100 199121 371377 699508 1325644 2516179 4760164 +4 10 13 21 54 145 354 811 1809 3978 8603 18243 38040 78607 162360 336928 702302 1463330 3026945 6175365 12364070 +10 8 11 31 98 285 753 1834 4180 9017 18554 36601 69435 126909 223731 380793 626552 999169 1552444 2374953 3647248 +19 40 84 160 276 435 624 790 790 291 -1419 -5767 -15459 -35380 -73969 -145243 -271683 -488238 -847750 -1428154 -2341862 +14 43 93 173 304 526 902 1525 2553 4341 7834 15569 33963 78133 181475 413923 915704 1958227 4051483 8129221 15860578 +6 20 51 103 175 263 379 597 1147 2606 6288 15025 34674 76901 164106 337791 672268 1296392 2427025 4419235 7839857 +13 39 76 124 183 253 334 426 529 643 768 904 1051 1209 1378 1558 1749 1951 2164 2388 2623 +4 -1 -9 -7 43 214 628 1476 3054 5851 10788 19844 37580 74592 154874 330788 712441 1523884 3208630 6624772 13400566 +14 32 77 159 296 538 1016 2041 4302 9261 19937 42440 88907 182978 369749 733466 1428528 2733658 5147659 9562961 17590460 +17 23 46 108 236 457 797 1285 1965 2928 4407 7073 12922 27730 67292 172119 440005 1094960 2628512 6083285 13614340 +15 40 77 128 197 293 437 681 1159 2214 4697 10638 24677 56955 128649 282047 598063 1225460 2427861 4656972 8663413 +10 15 29 70 180 435 955 1914 3550 6175 10185 16070 24424 35955 51495 72010 98610 132559 175285 228390 293660 +8 14 25 49 106 225 445 843 1622 3305 7104 15573 33718 70832 143456 280045 528148 965200 1714379 2967409 5016698 +7 30 69 139 265 482 835 1379 2179 3310 4857 6915 9589 12994 17255 22507 28895 36574 45709 56475 69057 +-9 -10 -11 -19 -44 -99 -200 -366 -619 -984 -1489 -2165 -3046 -4169 -5574 -7304 -9405 -11926 -14919 -18439 -22544 +3 15 32 67 148 317 627 1137 1905 2979 4386 6119 8122 10273 12365 14085 14991 14487 11796 5931 -4336 +12 27 51 99 207 456 1011 2172 4425 8467 15160 25345 39418 56536 73282 81574 65554 -2861 -170143 -509473 -1131727 +15 28 52 100 193 363 648 1076 1647 2344 3234 4756 8333 17487 39678 89128 190927 386748 742520 1358420 2381545 +16 36 79 157 292 530 971 1828 3528 6868 13239 24931 45532 80434 137459 227618 366016 572916 874975 1306665 1911892 +11 24 57 123 247 478 901 1649 2915 4964 8145 12903 19791 29482 42781 60637 84155 114608 153449 202323 263079 +2 11 30 71 156 327 669 1346 2650 5063 9332 16557 28292 46659 74475 115392 174050 256243 369098 521267 723132 +10 16 28 49 82 138 248 482 989 2103 4627 10528 24468 56877 129688 286558 610880 1258428 2520049 4949814 9638412 +-6 -13 -16 -2 54 193 477 1007 1986 3905 8017 17408 39198 88762 197499 426983 895209 1827026 3654553 7221609 14201993 +19 34 67 126 219 354 539 782 1091 1474 1939 2494 3147 3906 4779 5774 6899 8162 9571 11134 12859 +5 8 2 -20 -67 -150 -280 -459 -661 -805 -724 -119 1577 5693 15954 43288 118641 324450 866702 2230130 5494941 +22 41 71 118 188 287 421 596 818 1093 1427 1826 2296 2843 3473 4192 5006 5921 6943 8078 9332 +10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 +24 46 74 112 172 274 446 724 1152 1782 2674 3896 5524 7642 10342 13724 17896 22974 29082 36352 44924 +12 21 46 105 225 444 829 1522 2829 5386 10490 20804 41887 85448 176002 363890 749646 1527751 3062282 6013303 11541609 +17 26 44 78 143 278 573 1223 2636 5640 11874 24524 49696 98945 193893 374650 715219 1351738 2534080 4719142 8736701 +6 13 21 35 67 144 336 819 1989 4646 10279 21511 42814 81685 150592 270161 474288 818131 1390273 2330755 3857165 +7 30 67 121 200 315 488 787 1412 2867 6264 13823 29684 61291 121966 236148 450833 861732 1674524 3348890 6933206 +18 38 62 88 110 110 47 -149 -553 -1139 -1497 -195 6568 27734 82991 213847 504852 1122868 2387144 4890010 9697942 +21 40 84 180 366 691 1228 2124 3720 6777 12851 24890 48198 92044 172425 316931 573625 1028163 1838946 3312975 6073276 +13 16 24 43 90 199 425 846 1563 2698 4390 6789 10048 14313 19711 26336 34233 43380 53668 64879 76662 +16 38 65 91 104 80 -15 -189 -302 228 3016 11764 33984 83632 184924 377624 724100 1318434 2297843 3856617 6262704 +16 35 56 90 164 321 626 1189 2233 4279 8617 18424 41239 94099 213601 474649 1023894 2137171 4314958 8436510 16002462 +8 11 25 58 114 196 319 541 1020 2105 4469 9292 18502 35082 63451 109927 183280 295383 461969 703502 1046170 +9 26 61 123 223 378 621 1030 1799 3384 6767 13891 28329 56260 107835 199026 354061 608558 1013481 1640051 2585755 +3 4 9 26 73 193 493 1224 2921 6621 14172 28645 54901 100546 178041 310010 542455 975650 1831431 3590528 7257377 +7 22 56 130 287 605 1226 2413 4643 8746 16117 29071 51493 90071 156607 272198 474487 829726 1452094 2533600 4389003 +5 10 20 37 81 206 527 1279 2949 6545 14087 29419 59440 115817 217138 391246 677169 1125796 1798814 2767773 4122231 +20 26 32 38 44 50 56 62 68 74 80 86 92 98 104 110 116 122 128 134 140 +3 1 -1 -3 -5 -7 -9 -11 -13 -15 -17 -19 -21 -23 -25 -27 -29 -31 -33 -35 -37 +28 51 91 155 250 383 561 791 1080 1435 1863 2371 2966 3655 4445 5343 6356 7491 8755 10155 11698 +4 13 35 94 232 514 1042 1990 3675 6691 12171 22331 41632 79252 154256 306231 616908 1253763 2557209 5212882 10586110 +13 33 82 176 333 573 918 1392 2021 2833 3858 5128 6677 8541 10758 13368 16413 19937 23986 28608 33853 +-6 5 40 122 290 603 1151 2088 3711 6618 11987 22027 40661 74510 134256 236471 406008 679059 1106994 1761104 2738380 +-8 -3 24 86 197 386 733 1448 3027 6535 14088 29637 60200 117746 222011 404623 715034 1228905 2059768 3375000 5417391 +11 30 50 76 123 231 498 1143 2634 5968 13286 29161 63126 134327 279608 566876 1116269 2132474 3952530 7114618 12454701 +9 15 28 58 128 285 611 1234 2339 4179 7086 11482 17890 26945 39405 56162 78253 106871 143376 189306 246388 +0 9 21 43 108 289 713 1575 3152 5817 10053 16467 25804 38961 57001 81167 112896 153833 205845 271035 351756 +0 8 26 68 152 302 557 987 1716 2952 5024 8426 13868 22334 35147 54041 81240 119544 172422 244112 339728 +8 13 27 67 165 374 777 1507 2794 5059 9071 16170 28546 49593 84567 142544 242872 434749 850659 1839189 4270263 +23 32 50 87 152 262 476 975 2225 5296 12479 28473 62661 133455 276516 560064 1112783 2173388 4176252 7895207 14678482 +8 21 59 143 310 618 1162 2114 3802 6851 12429 22680 41504 76024 139523 257691 482385 922056 1807818 3632770 7436279 +25 49 92 161 271 455 773 1321 2242 3733 6021 9243 13106 16119 14076 -2677 -53841 -176503 -436358 -944275 -1880039 +11 17 44 110 241 469 835 1402 2280 3662 5867 9383 14900 23320 35728 53305 77161 108063 146030 189764 235883 +21 26 27 28 45 120 343 897 2153 4854 10439 21570 42937 82428 152763 273703 474957 799922 1310403 2092472 3263637 +15 28 52 92 167 320 628 1212 2247 3972 6700 10828 16847 25352 37052 52780 73503 100332 134532 177532 230935 +12 28 55 104 205 423 888 1855 3824 7775 15620 31073 61362 120703 237495 469218 932688 1863586 3729301 7434750 14684007 +5 12 24 59 150 354 765 1529 2859 5048 8478 13623 21044 31374 45291 63477 86561 115044 149204 188979 233826 +11 13 17 19 16 22 108 479 1601 4391 10483 22583 44926 83848 148486 251619 410663 648833 996485 1492651 2186780 +-6 -15 -24 -26 -3 87 337 941 2290 5160 11074 22982 46513 92242 179723 344515 650130 1207827 2208540 3973046 7028845 +5 17 49 116 256 546 1120 2195 4116 7436 13052 22423 37901 63211 104121 169348 271751 429867 669851 1027886 1553134 +21 40 71 118 195 346 682 1442 3093 6497 13192 25856 49037 90215 161175 279454 469197 760006 1181149 1746634 2423927 +5 2 12 47 135 347 835 1891 4047 8245 16114 30398 55585 98792 170965 288456 475041 764444 1203432 1855545 2805523 +9 8 18 61 175 419 877 1669 2995 5280 9573 18513 38472 84044 187112 414731 903761 1926772 4015068 8183461 16331553 +13 33 74 151 298 586 1149 2218 4163 7543 13164 22145 35992 56680 86743 129372 188521 269021 376702 518523 702710 +3 -3 -11 -21 -33 -47 -63 -81 -101 -123 -147 -173 -201 -231 -263 -297 -333 -371 -411 -453 -497 +17 31 48 61 68 86 168 417 1001 2205 4618 9653 20744 45764 101470 221113 466761 948379 1852300 3482413 6318196 +3 16 50 117 227 389 612 906 1283 1758 2350 3083 3987 5099 6464 8136 10179 12668 15690 19345 23747 +-4 -5 -4 4 28 81 180 346 604 983 1516 2240 3196 4429 5988 7926 10300 13171 16604 20668 25436 +5 8 7 6 20 94 340 995 2512 5713 12053 24062 46043 85103 152576 265857 450599 743126 1192779 1863734 2835606 +8 31 77 165 324 597 1045 1751 2824 4403 6661 9809 14100 19833 27357 37075 49448 64999 84317 108061 136964 +19 28 37 46 55 64 73 82 91 100 109 118 127 136 145 154 163 172 181 190 199 +16 25 48 106 230 461 850 1458 2356 3625 5356 7650 10618 14381 19070 24826 31800 40153 50056 61690 75246 +-7 4 43 131 307 640 1242 2293 4105 7276 13015 23759 44270 83526 157946 296859 551720 1011669 1830570 3277360 5839008 +-9 -9 -4 1 -4 -34 -109 -254 -499 -879 -1434 -2209 -3254 -4624 -6379 -8584 -11309 -14629 -18624 -23379 -28984 +1 -3 -7 -11 -15 -19 -23 -27 -31 -35 -39 -43 -47 -51 -55 -59 -63 -67 -71 -75 -79 +24 46 91 174 317 568 1048 2054 4273 9217 20082 43371 91804 189265 378801 734981 1382230 2521056 4464365 7686284 12886055 +8 8 -2 -17 -7 98 423 1163 2598 5108 9188 15463 24703 37838 55973 80403 112628 154368 207578 274463 357493 +-1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 +1 7 27 87 229 509 989 1737 2876 4760 8401 16335 34221 73667 157197 327240 663367 1317719 2592147 5111533 10215129 +7 25 62 133 265 514 991 1897 3567 6523 11536 19697 32497 51916 80521 121573 179143 258237 364930 506509 691625 +10 14 22 32 50 103 251 592 1258 2410 4256 7138 11762 19679 34165 61694 114250 212782 392170 708140 1246642 +17 40 83 153 261 428 688 1088 1685 2540 3709 5231 7113 9312 11714 14110 16169 17408 17159 14533 8381 +17 36 65 122 248 532 1163 2526 5364 11030 21844 41538 75706 132075 220299 350924 533378 773823 1076714 1461725 2026063 +-4 11 54 151 345 706 1358 2535 4678 8585 15626 28035 49291 84600 141490 230531 366192 567847 860942 1278335 1861821 +11 25 52 107 229 498 1056 2139 4137 7709 13990 24937 43871 76282 130974 221637 368943 603273 968192 1524799 2357089 +7 18 38 88 213 494 1060 2100 3875 6730 11106 17552 26737 39462 56672 79468 109119 147074 194974 254664 328205 +2 -2 -3 6 43 157 466 1227 2964 6711 14492 30274 61807 124022 245009 476057 907822 1695412 3096055 5524062 9629027 +12 18 25 38 70 158 392 963 2240 4890 10070 19772 37532 69978 130161 244373 465308 896082 1731927 3329458 6317442 +10 36 72 115 156 180 177 168 257 746 2412 7178 19683 50794 125115 296361 677564 1498152 3207936 6660213 13424182 +9 7 1 5 44 158 415 938 1963 3961 7872 15505 30140 57314 105708 188096 322752 537022 877598 1436960 2412475 +10 12 16 22 30 40 52 66 82 100 120 142 166 192 220 250 282 316 352 390 430 +5 5 18 56 143 336 762 1685 3622 7533 15117 29254 54642 98688 172723 293623 485931 784589 1238404 1914388 2903129 +7 17 29 39 55 119 341 951 2381 5398 11321 22370 42213 76797 135564 233137 391443 641859 1026001 1591637 2375891 +6 24 51 97 196 430 978 2210 4848 10209 20523 39272 71416 123271 201752 312893 460481 648312 896096 1293659 2149323 +-10 -20 -34 -41 -6 151 583 1551 3466 6938 12832 22331 37006 58893 90577 135283 196974 280456 391490 536911 724754 +18 16 13 13 20 38 71 123 198 300 433 601 808 1058 1355 1703 2106 2568 3093 3685 4348 +5 -1 -10 -22 -37 -55 -76 -100 -127 -157 -190 -226 -265 -307 -352 -400 -451 -505 -562 -622 -685 +21 30 50 108 241 490 903 1554 2587 4306 7366 13209 25104 50620 107297 235005 521468 1152350 2505083 5317532 10980358 +14 24 51 113 249 541 1151 2376 4722 8996 16413 28713 48281 78261 122653 186380 275310 396216 556655 764745 1028817 +27 54 94 144 212 339 625 1254 2513 4800 8616 14536 23154 34997 50403 69358 91287 114794 137346 154896 161440 +25 44 70 102 139 180 224 270 317 364 410 454 495 532 564 590 609 620 622 614 595 +0 -5 -8 -3 16 55 120 217 352 531 760 1045 1392 1807 2296 2865 3520 4267 5112 6061 7120 +25 50 92 166 294 517 934 1795 3691 7908 17053 36143 74542 149591 293799 569558 1099317 2126198 4131866 8057412 15702182 +1 8 25 56 112 216 406 739 1307 2286 4063 7545 14874 30996 66968 146821 321908 701382 1517474 3264258 6986099 +12 16 33 69 139 290 650 1528 3595 8173 17658 36122 70195 130423 233397 404944 684330 1128302 1811111 2811119 4164151 +11 28 55 113 237 476 893 1565 2583 4052 6091 8833 12425 17028 22817 29981 38723 49260 61823 76657 94021 +-3 -8 -6 10 49 121 241 460 964 2303 5832 14471 33938 74702 155073 306155 580004 1063685 1904959 3361895 5902000 +28 49 82 131 201 314 551 1142 2632 6153 13832 29368 58825 111724 202589 353227 596220 980401 1579502 2505729 3930769 +2 9 36 92 186 335 580 1027 1957 4089 9139 20903 47207 103221 216878 437667 851459 1607769 2975441 5465694 10112987 +-9 -3 27 104 255 504 872 1401 2241 3880 7671 16950 39307 91069 205930 451127 956891 1968455 3935123 7658340 14531007 +14 28 61 128 252 484 938 1842 3606 6908 12799 22828 39188 64884 103924 161534 244398 360924 521537 739000 1028764 +3 5 2 -6 -19 -37 -60 -88 -121 -159 -202 -250 -303 -361 -424 -492 -565 -643 -726 -814 -907 +5 0 -13 -41 -81 -97 12 453 1589 3998 8541 16439 29359 49509 79742 123669 185781 271580 387719 542151 744287 +14 32 71 157 330 639 1129 1816 2647 3457 3973 3996 4065 7274 23660 80026 240759 650145 1615746 3769158 8371603 +2 10 29 59 100 152 215 289 374 470 577 695 824 964 1115 1277 1450 1634 1829 2035 2252 +0 -9 -28 -58 -86 -77 37 383 1208 3017 6879 15078 32411 68601 142546 289667 575029 1118532 2147023 4106679 7906081 +-5 -5 -1 6 25 94 319 950 2524 6137 13970 30308 63502 129740 260352 516166 1016105 1994503 3915537 7698738 15154775 +12 15 18 16 -3 -53 -138 -233 -258 -45 702 2454 5911 12063 22258 38277 62416 97575 147354 216156 309297 +13 19 23 24 19 3 -22 -21 126 712 2345 6188 14400 30992 63498 126149 245659 471321 891907 1662912 3049025 +-3 -8 -23 -48 -63 -18 184 726 1952 4502 9569 19428 38564 76073 150698 301254 608073 1237141 2531329 5199651 10709513 +17 24 35 57 97 162 259 395 577 812 1107 1469 1905 2422 3027 3727 4529 5440 6467 7617 8897 +3 1 -8 -15 -2 53 168 346 561 741 748 355 -780 -3143 -7396 -14412 -25313 -41511 -64752 -97163 -141302 +24 38 59 105 216 465 968 1906 3592 6654 12479 24194 48684 100551 209707 435902 896760 1822390 3662127 7292243 14415680 +9 28 62 116 195 304 448 632 861 1140 1474 1868 2327 2856 3460 4144 4913 5772 6726 7780 8939 +16 26 42 71 120 196 306 457 656 910 1226 1611 2072 2616 3250 3981 4816 5762 6826 8015 9336 +7 19 54 123 237 407 644 959 1363 1867 2482 3219 4089 5103 6272 7607 9119 10819 12718 14827 17157 +17 43 83 136 211 342 616 1219 2505 5095 10013 18858 33994 58740 97658 157520 250909 407643 705951 1348200 2828953 +3 9 13 23 59 153 349 703 1283 2169 3453 5239 7643 10793 14829 19903 26179 33833 43053 54039 67003 +16 34 61 102 168 288 530 1031 2036 3946 7375 13216 22716 37560 59964 92777 139592 204866 294049 413722 571744 +2 -5 -18 -31 -23 49 258 725 1665 3484 6957 13541 25942 49194 92763 174611 328804 619193 1163016 2170049 4005271 +-2 7 31 85 206 471 1033 2199 4586 9398 18865 36870 69758 127268 223451 377330 612918 958033 1441131 2085115 2896766 +5 17 37 73 146 298 603 1190 2286 4281 7806 13799 23513 38394 59726 87904 121155 153481 171547 150181 46092 +27 45 70 114 202 375 693 1238 2117 3465 5448 8266 12156 17395 24303 33246 44639 58949 76698 98466 124894 +-9 0 23 61 115 186 275 383 511 660 831 1025 1243 1486 1755 2051 2375 2728 3111 3525 3971 +28 45 62 80 107 163 286 553 1154 2591 6118 14592 33969 75753 160790 324893 626888 1159785 2065902 3556904 5939863 +7 19 42 91 180 325 552 908 1474 2380 3823 6090 9589 14892 22795 34401 51233 75385 109720 158125 225834 +5 22 56 121 254 528 1067 2065 3823 6844 12066 21367 38544 71050 132869 249019 462297 843018 1502652 2612429 4428162 +28 46 66 89 120 179 327 710 1631 3684 8031 16983 35185 71962 145872 293429 585614 1158646 2270192 4399649 8422518 +16 43 95 182 314 501 753 1080 1492 1999 2611 3338 4190 5177 6309 7596 9048 10675 12487 14494 16706 +21 35 49 76 156 372 866 1859 3686 6867 12252 21305 36632 62922 108597 188761 330727 584923 1047099 1903726 3523224 +14 40 81 147 267 499 946 1785 3316 6034 10726 18616 31655 53223 89831 154950 276930 514196 982623 1902313 3674051 +12 15 31 81 214 534 1239 2686 5521 10951 21300 41112 79299 153303 297198 577578 1124802 2194083 4283165 8354103 16240436 +28 58 112 197 318 478 678 917 1192 1498 1828 2173 2522 2862 3178 3453 3668 3802 3832 3733 3478 +22 32 42 52 62 72 82 92 102 112 122 132 142 152 162 172 182 192 202 212 222 +4 16 40 77 128 194 276 375 492 628 784 961 1160 1382 1628 1899 2196 2520 2872 3253 3664 +10 25 40 55 70 85 100 115 130 145 160 175 190 205 220 235 250 265 280 295 310 +18 32 57 89 128 188 324 693 1669 4042 9357 20516 42928 86845 172217 338655 665208 1308032 2569157 5017063 9690412 +12 15 17 18 18 17 15 12 8 3 -3 -10 -18 -27 -37 -48 -60 -73 -87 -102 -118 +-7 -15 -17 10 112 376 962 2162 4505 8933 17079 31684 57196 100600 172534 288752 472001 754385 1180295 1809990 2723920 +18 36 60 88 117 157 267 629 1693 4462 11050 25761 57153 121962 252528 510742 1013885 1981521 3818321 7255643 13584618 +10 36 79 152 284 529 990 1870 3573 6912 13561 27049 54891 112982 234333 485961 1000908 2038072 4092599 8096822 15780334 +7 21 48 92 153 230 337 538 1006 2110 4533 9423 18578 34665 61472 104191 169729 267043 407494 605214 877479 +7 9 11 5 -17 -49 -37 181 963 2978 7352 15882 31453 59024 108045 198180 372191 723527 1452693 2977459 6139555 +24 44 70 117 223 465 983 2011 3916 7262 12968 22753 40309 74085 143291 289853 600704 1247144 2551234 5093525 9882115 +7 24 53 94 147 212 289 378 479 592 717 854 1003 1164 1337 1522 1719 1928 2149 2382 2627 +7 30 68 121 189 272 370 483 611 754 912 1085 1273 1476 1694 1927 2175 2438 2716 3009 3317 +20 35 64 134 298 649 1351 2701 5236 9899 18278 32932 57818 98833 164485 266707 421828 651715 985100 1459106 2120986 +-5 3 23 54 90 126 182 357 934 2574 6660 15887 35265 73865 148016 287528 548481 1040512 1986179 3850725 7624076 +-1 7 40 124 292 577 1003 1586 2382 3672 6477 13787 33242 82670 201151 470639 1057469 2290613 4806298 9809414 19535028 +10 25 56 110 194 323 538 934 1698 3157 5836 10526 18362 30911 50270 79174 121114 180465 262624 374158 522962 +16 45 92 161 271 479 913 1815 3602 6973 13129 24243 44441 81788 152260 287789 553028 1081233 2151922 4357685 8954707 +23 44 77 123 187 285 453 760 1320 2281 3743 5539 6852 5839 -27 -11000 -15275 36046 284913 1080971 3202209 +6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 +17 27 30 23 4 -24 -34 75 588 2195 6405 16275 37625 80968 164451 318179 590379 1055955 1828088 3073647 5033298 +6 10 24 50 96 196 453 1112 2666 5993 12517 24386 44672 77631 129139 207624 326374 509569 807945 1338024 2375922 +10 8 1 -11 -28 -50 -77 -109 -146 -188 -235 -287 -344 -406 -473 -545 -622 -704 -791 -883 -980 +4 18 40 74 126 203 313 467 684 1000 1482 2248 3494 5529 8819 14041 22148 34446 52684 79158 116830 +1 9 37 99 225 473 955 1887 3674 7063 13455 25576 48882 94329 183491 357472 691647 1318997 2465689 4503609 8025799 +-2 3 32 109 267 548 1003 1692 2684 4057 5898 8303 11377 15234 19997 25798 32778 41087 50884 62337 75623 +28 48 68 97 153 261 464 865 1738 3781 8643 19952 45214 99153 209322 425129 831772 1570930 2870362 5084751 8750099 +13 22 41 86 176 326 538 792 1039 1198 1159 794 -22 -1378 -3280 -5588 -7935 -9626 -9515 -5858 3860 +13 37 81 154 258 387 543 791 1388 3046 7440 18165 42492 94470 200144 405845 790539 1482930 2683273 4688909 7922790 diff --git a/day_09/src/lib.rs b/day_09/src/lib.rs new file mode 100644 index 0000000..1447f64 --- /dev/null +++ b/day_09/src/lib.rs @@ -0,0 +1,55 @@ +use nom::{ + character::complete, + multi::separated_list1, + IResult, +}; +use ndarray::prelude::*; + +fn parse_line(input: &str) -> IResult<&str, Vec> { + separated_list1(complete::space1, complete::i64)(input) +} + +fn expand(sequence: Vec) -> Array2 { + let mut reduced = Array::zeros((sequence.len()+1, sequence.len()+1)); + reduced.slice_mut(s!(0,0..sequence.len())).assign(&Array::from_vec(sequence.clone())); + for i in 1..sequence.len()-1 { + for j in 1..i { + reduced[[j,i+1-j]] = reduced[[0,3]] - reduced[[0,2]]; + reduced[[j,i+1-j]] = reduced[[j-1,i+2-j]] - reduced[[j-1,i+1-j]]; + } + reduced[[i,0]] = reduced[[i-1,1]] - reduced[[i-1,0]]; + reduced[[i,1]] = reduced[[i-1,2]] - reduced[[i-1,1]]; + } + reduced +} + +fn extrapolate(mut reduced: Array2) -> i64 { + let first_i = reduced.outer_iter().position(|row| {row.sum() == 0}).unwrap() - 1; + let mut j = reduced.slice(s!(first_i,..)).iter().position(|value| {value == &0}).unwrap(); + for i in (0..=first_i).rev() { + reduced[[i,j]] = reduced[[i, j-1]] + reduced[[i+1, j-1]]; + j += 1; + } + reduced[[0, reduced.shape()[1]-1]] +} + +pub fn part1(input: &str) -> String { + input.lines().map(|line| { + parse_line(line).unwrap().1 + }).map(|x| { + dbg!(&x); + let reduced = expand(x); + dbg!(extrapolate(reduced.clone())); + extrapolate(reduced) + }).sum::().to_string() +} + +pub fn part2(input: &str) -> String { + todo!() +} + +pub mod prelude { + pub use super::part1; + pub use super::part2; +} + diff --git a/day_09/src/main.rs b/day_09/src/main.rs new file mode 100644 index 0000000..0c70f17 --- /dev/null +++ b/day_09/src/main.rs @@ -0,0 +1,28 @@ +use day_09::prelude::*; + +fn main() { + let input = include_str!("../input.txt"); + println!("{}", part1(input)); + println!("{}", part2(input)); +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_part1() { + let test_input = "0 3 6 9 12 15 +1 3 6 10 15 21 +10 13 16 21 30 45"; + assert_eq!(part1(test_input), "114".to_string()); + panic!(); + } + + #[test] + fn test_part2() { + let test_input = ""; + assert_eq!(part2(test_input), "".to_string()); + } + +}