This commit is contained in:
sepia 2024-12-14 14:34:29 -06:00
parent a91b120155
commit 290789d5f5
5 changed files with 571 additions and 27 deletions

415
Cargo.lock generated
View File

@ -22,14 +22,21 @@ name = "advent"
version = "0.1.0"
dependencies = [
"dotenvy",
"itertools",
"itertools 0.13.0",
"pest",
"pest_derive",
"raylib",
"rayon",
"regex",
"reqwest",
]
[[package]]
name = "ahash"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8fd72866655d1904d6b0997d0b07ba561047d070fbe29de039031c641b61217"
[[package]]
name = "aho-corasick"
version = "1.1.3"
@ -39,6 +46,12 @@ dependencies = [
"memchr",
]
[[package]]
name = "arrayvec"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
[[package]]
name = "atomic-waker"
version = "1.1.2"
@ -58,7 +71,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a"
dependencies = [
"addr2line",
"cfg-if",
"cfg-if 1.0.0",
"libc",
"miniz_oxide",
"object",
@ -72,6 +85,29 @@ version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
[[package]]
name = "bindgen"
version = "0.69.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088"
dependencies = [
"bitflags",
"cexpr",
"clang-sys",
"itertools 0.12.1",
"lazy_static",
"lazycell",
"log",
"prettyplease",
"proc-macro2",
"quote",
"regex",
"rustc-hash",
"shlex",
"syn 2.0.90",
"which",
]
[[package]]
name = "bitflags"
version = "2.6.0"
@ -108,12 +144,47 @@ dependencies = [
"shlex",
]
[[package]]
name = "cexpr"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
dependencies = [
"nom",
]
[[package]]
name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clang-sys"
version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4"
dependencies = [
"glob",
"libc",
"libloading",
]
[[package]]
name = "cmake"
version = "0.1.52"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c682c223677e0e5b6b7f63a64b9351844c3f1b1678a68b7ee617e30fb082620e"
dependencies = [
"cc",
]
[[package]]
name = "core-foundation"
version = "0.9.4"
@ -146,7 +217,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d"
dependencies = [
"crossbeam-epoch",
"crossbeam-utils",
"crossbeam-utils 0.8.20",
]
[[package]]
@ -155,7 +226,29 @@ version = "0.9.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
dependencies = [
"crossbeam-utils",
"crossbeam-utils 0.8.20",
]
[[package]]
name = "crossbeam-queue"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570"
dependencies = [
"cfg-if 0.1.10",
"crossbeam-utils 0.7.2",
"maybe-uninit",
]
[[package]]
name = "crossbeam-utils"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8"
dependencies = [
"autocfg",
"cfg-if 0.1.10",
"lazy_static",
]
[[package]]
@ -192,7 +285,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
]
[[package]]
@ -213,7 +306,7 @@ version = "0.8.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
]
[[package]]
@ -268,6 +361,12 @@ dependencies = [
"percent-encoding",
]
[[package]]
name = "fs_extra"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c"
[[package]]
name = "futures-channel"
version = "0.3.31"
@ -334,7 +433,7 @@ version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
"libc",
"wasi",
]
@ -345,6 +444,12 @@ version = "0.31.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
[[package]]
name = "glob"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
[[package]]
name = "h2"
version = "0.4.7"
@ -364,12 +469,37 @@ dependencies = [
"tracing",
]
[[package]]
name = "hashbrown"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96282e96bfcd3da0d3aa9938bedf1e50df3269b6db08b4876d2da0bb1a0841cf"
dependencies = [
"ahash",
"autocfg",
]
[[package]]
name = "hashbrown"
version = "0.15.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289"
[[package]]
name = "hibitset"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3ede5cfa60c958e60330d65163adbc4211e15a2653ad80eb0cce878de120121"
[[package]]
name = "home"
version = "0.5.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5"
dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "http"
version = "1.2.0"
@ -597,7 +727,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
]
[[package]]
@ -628,7 +758,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f"
dependencies = [
"equivalent",
"hashbrown",
"hashbrown 0.15.2",
]
[[package]]
@ -637,6 +767,15 @@ version = "2.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708"
[[package]]
name = "itertools"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569"
dependencies = [
"either",
]
[[package]]
name = "itertools"
version = "0.13.0"
@ -662,12 +801,34 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "lazy_static"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
[[package]]
name = "lazycell"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]]
name = "libc"
version = "0.2.167"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc"
[[package]]
name = "libloading"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34"
dependencies = [
"cfg-if 1.0.0",
"windows-targets",
]
[[package]]
name = "linux-raw-sys"
version = "0.4.14"
@ -680,12 +841,28 @@ version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104"
[[package]]
name = "lock_api"
version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17"
dependencies = [
"autocfg",
"scopeguard",
]
[[package]]
name = "log"
version = "0.4.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
[[package]]
name = "maybe-uninit"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
[[package]]
name = "memchr"
version = "2.7.4"
@ -698,6 +875,12 @@ version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
[[package]]
name = "minimal-lexical"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "miniz_oxide"
version = "0.8.0"
@ -718,6 +901,12 @@ dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "mopa"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a785740271256c230f57462d3b83e52f998433a7062fc18f96d5999474a9f915"
[[package]]
name = "native-tls"
version = "0.2.12"
@ -735,6 +924,16 @@ dependencies = [
"tempfile",
]
[[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 = "object"
version = "0.36.5"
@ -757,7 +956,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5"
dependencies = [
"bitflags",
"cfg-if",
"cfg-if 1.0.0",
"foreign-types",
"libc",
"once_cell",
@ -773,7 +972,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
]
[[package]]
@ -794,6 +993,29 @@ dependencies = [
"vcpkg",
]
[[package]]
name = "parking_lot"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27"
dependencies = [
"lock_api",
"parking_lot_core",
]
[[package]]
name = "parking_lot_core"
version = "0.9.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
dependencies = [
"cfg-if 1.0.0",
"libc",
"redox_syscall",
"smallvec",
"windows-targets",
]
[[package]]
name = "percent-encoding"
version = "2.3.1"
@ -831,7 +1053,7 @@ dependencies = [
"pest_meta",
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
]
[[package]]
@ -863,6 +1085,16 @@ version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2"
[[package]]
name = "prettyplease"
version = "0.2.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033"
dependencies = [
"proc-macro2",
"syn 2.0.90",
]
[[package]]
name = "proc-macro2"
version = "1.0.92"
@ -881,6 +1113,33 @@ dependencies = [
"proc-macro2",
]
[[package]]
name = "raylib"
version = "5.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2a7a6734329d7b872a418fe4cb08ca282eb66a6f4a3430bd4ee4e6a8cac6632"
dependencies = [
"cfg-if 1.0.0",
"lazy_static",
"libc",
"parking_lot",
"raylib-sys",
"specs",
"specs-derive",
]
[[package]]
name = "raylib-sys"
version = "5.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db5c6001cfaeec17210713227d11f3b1ba4b723bb12cff47d1b93c4060e10ad0"
dependencies = [
"bindgen",
"cc",
"cmake",
"fs_extra",
]
[[package]]
name = "rayon"
version = "1.10.0"
@ -898,7 +1157,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2"
dependencies = [
"crossbeam-deque",
"crossbeam-utils",
"crossbeam-utils 0.8.20",
]
[[package]]
name = "redox_syscall"
version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834"
dependencies = [
"bitflags",
]
[[package]]
@ -981,7 +1249,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d"
dependencies = [
"cc",
"cfg-if",
"cfg-if 1.0.0",
"getrandom",
"libc",
"spin",
@ -995,6 +1263,12 @@ version = "0.1.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
[[package]]
name = "rustc-hash"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "rustix"
version = "0.38.41"
@ -1062,6 +1336,12 @@ dependencies = [
"windows-sys 0.59.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.11.1"
@ -1102,7 +1382,7 @@ checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
]
[[package]]
@ -1135,7 +1415,7 @@ version = "0.10.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
"cpufeatures",
"digest",
]
@ -1146,6 +1426,25 @@ version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
name = "shred"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c5f08237e667ac94ad20f8878b5943d91a93ccb231428446c57c21c57779016d"
dependencies = [
"arrayvec",
"hashbrown 0.7.2",
"mopa",
"smallvec",
"tynm",
]
[[package]]
name = "shrev"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5ea33232fdcf1bf691ca33450e5a94dde13e1a8cbb8caabc5e4f9d761e10b1a"
[[package]]
name = "slab"
version = "0.4.9"
@ -1171,6 +1470,32 @@ dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "specs"
version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fff28a29366aff703d5da8a7e2c8875dc8453ac1118f842cbc0fa70c7db51240"
dependencies = [
"crossbeam-queue",
"hashbrown 0.7.2",
"hibitset",
"log",
"shred",
"shrev",
"tuple_utils",
]
[[package]]
name = "specs-derive"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e23e09360f3d2190fec4222cd9e19d3158d5da948c0d1ea362df617dd103511"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "spin"
version = "0.9.8"
@ -1189,6 +1514,17 @@ version = "2.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
[[package]]
name = "syn"
version = "1.0.109"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "syn"
version = "2.0.90"
@ -1217,7 +1553,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
]
[[package]]
@ -1247,7 +1583,7 @@ version = "3.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
"fastrand",
"once_cell",
"rustix",
@ -1271,7 +1607,7 @@ checksum = "d65750cab40f4ff1929fb1ba509e9914eb756131cef4210da8d5d700d26f6312"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
]
[[package]]
@ -1364,6 +1700,21 @@ version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
[[package]]
name = "tuple_utils"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44834418e2c5b16f47bedf35c28e148db099187dd5feee6367fb2525863af4f1"
[[package]]
name = "tynm"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd30d05e69d1478e13fe3e7a853409cfec82cebc2cf9b8d613b3c6b0081781ed"
dependencies = [
"nom",
]
[[package]]
name = "typenum"
version = "1.17.0"
@ -1444,7 +1795,7 @@ version = "0.2.97"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d15e63b4482863c109d70a7b8706c1e364eb6ea449b201a76c5b89cedcec2d5c"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
"once_cell",
"wasm-bindgen-macro",
]
@ -1460,7 +1811,7 @@ dependencies = [
"once_cell",
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
"wasm-bindgen-shared",
]
@ -1470,7 +1821,7 @@ version = "0.4.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9dfaf8f50e5f293737ee323940c7d8b08a66a95a419223d9f41610ca08b0833d"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
"js-sys",
"once_cell",
"wasm-bindgen",
@ -1495,7 +1846,7 @@ checksum = "98c9ae5a76e46f4deecd0f0255cc223cfa18dc9b261213b8aa0c7b36f61b3f1d"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
@ -1516,6 +1867,18 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "which"
version = "4.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7"
dependencies = [
"either",
"home",
"once_cell",
"rustix",
]
[[package]]
name = "windows-registry"
version = "0.2.0"
@ -1660,7 +2023,7 @@ checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
"synstructure",
]
@ -1681,7 +2044,7 @@ checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
"synstructure",
]
@ -1710,5 +2073,5 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 2.0.90",
]

View File

@ -8,6 +8,7 @@ dotenvy = "0.15.7"
itertools = "0.13.0"
pest = "2.7.15"
pest_derive = "2.7.15"
raylib = "5.0.2"
rayon = "1.10.0"
regex = "1.11.1"
reqwest = { version = "0.12.9", features = ["blocking"] }

169
src/day14.rs Normal file
View File

@ -0,0 +1,169 @@
use itertools::Itertools;
use pest::{
iterators::{Pair, Pairs},
Parser,
};
use raylib::prelude::*;
use rayon::prelude::*;
const WIDTH: i64 = 101;
const HEIGHT: i64 = 103;
#[derive(Copy, Clone, PartialEq)]
enum PlayState {
Paused,
Forward(i64),
Backward(i64),
}
pub fn day14() {
let mut robots = parse_robots(&crate::input(14));
let (mut rl, thread) = raylib::init()
.size(1920, 1080)
.title("Advent of Code: Day 14")
.build();
let mut total_elapsed: u32 = 6440;
let mut play_state = PlayState::Forward(1);
let mut safety_score: usize = 0;
rl.set_target_fps(1);
while !rl.window_should_close() {
let pressed_key = rl.get_key_pressed();
match pressed_key {
Some(KeyboardKey::KEY_ENTER) => {
let mut quadrants: Vec<Vec<Robot>> = vec![vec![]; 4];
for robot in robots.iter() {
if let Some(quadrant) = robot.quadrant() {
quadrants[quadrant].push(*robot);
}
}
let safety_score = quadrants
.iter()
.map(Vec::len)
.reduce(|acc, e| acc * e)
.unwrap();
println!("Safety Score: {}", safety_score);
}
Some(KeyboardKey::KEY_D) => {
play_state = match play_state {
PlayState::Forward(speed) => PlayState::Forward((speed * 2).min(16)),
PlayState::Backward(speed) if speed == 1 => PlayState::Forward(1),
PlayState::Backward(speed) => PlayState::Backward(speed / 2),
_ => PlayState::Forward(1),
};
}
Some(KeyboardKey::KEY_A) => {
play_state = match play_state {
PlayState::Backward(speed) => PlayState::Backward((speed * 2).min(16)),
PlayState::Forward(speed) if speed == 1 => PlayState::Backward(1),
PlayState::Forward(speed) => PlayState::Forward(speed / 2),
_ => PlayState::Backward(1),
};
}
Some(KeyboardKey::KEY_SPACE) => {
play_state = match play_state {
PlayState::Paused => PlayState::Forward(1),
_ => PlayState::Paused,
};
let mut quadrants: Vec<usize> = vec![0; 4];
for robot in robots.iter() {
if let Some(q) = robot.quadrant() {
quadrants[q] += 1;
}
}
safety_score = quadrants.into_iter().reduce(|acc, e| acc * e).unwrap();
}
_ => {}
}
match play_state {
PlayState::Paused => {}
PlayState::Forward(speed) => {
rl.set_target_fps(speed as u32);
robots.par_iter_mut().for_each(|r| r.tick(1));
total_elapsed += 1;
}
PlayState::Backward(speed) => {
rl.set_target_fps(speed as u32);
robots.par_iter_mut().for_each(|r| r.tick(-1));
total_elapsed -= 1;
}
}
let mut d = rl.begin_drawing(&thread);
d.clear_background(Color::BLACK);
for robot in robots.iter() {
let x = (robot.p.0 as f32 / WIDTH as f32) * 1920.;
let y = (robot.p.1 as f32 / HEIGHT as f32) * 1080.;
d.draw_circle(x as i32, y as i32, 10., Color::GREEN);
}
d.draw_text(
format!("Elapsed: {}", total_elapsed).as_str(),
0,
0,
20,
Color::MAGENTA,
);
if play_state == PlayState::Paused {
d.draw_text(
format!("Safety Score: {}", safety_score).as_str(),
0,
40,
20,
Color::MAGENTA,
);
}
}
}
#[derive(Copy, Clone, Debug)]
struct Robot {
p: (i64, i64),
v: (i64, i64),
}
impl Robot {
fn tick(&mut self, delta: i64) {
self.p.0 = (self.p.0 + self.v.0 * delta).rem_euclid(WIDTH);
self.p.1 = (self.p.1 + self.v.1 * delta).rem_euclid(HEIGHT);
}
fn quadrant(&self) -> Option<usize> {
if self.p.0 == WIDTH / 2 || self.p.1 == HEIGHT / 2 {
return None;
}
Some(((self.p.1 > HEIGHT / 2) as usize) * 2 + (self.p.0 > WIDTH / 2) as usize)
}
}
#[derive(pest_derive::Parser)]
#[grammar = "grammars/day14.pest"]
struct RobotsParser {}
fn parse_robots(input: &str) -> Vec<Robot> {
RobotsParser::parse(Rule::robots, input)
.unwrap()
.nth(0)
.unwrap()
.into_inner()
.map(Pair::<'_, Rule>::into_inner)
.map(Robot::parse)
.collect()
}
impl Robot {
fn parse(input: Pairs<'_, Rule>) -> Self {
let (p, v) = input
.map(Pair::<'_, Rule>::into_inner)
.map(|a| {
a.map(|ns| ns.as_str().parse::<i64>().unwrap())
.collect_tuple()
.unwrap()
})
.collect_tuple()
.unwrap();
Self { p, v }
}
}

9
src/grammars/day14.pest Normal file
View File

@ -0,0 +1,9 @@
_WHITESPACE = _{ " " }
NEWLINE = _{ "\n" }
int = { "-"? ~ ASCII_DIGIT+ }
coord_statement = { ("p" | "v") ~ "=" ~ int ~ "," ~ int }
robot = { coord_statement ~ _WHITESPACE* ~ coord_statement ~ NEWLINE? }
eoi = _{ !ANY }
robots = { SOI ~ robot+ ~ eoi }

View File

@ -24,10 +24,12 @@ mod day10;
mod day11;
#[allow(dead_code)]
mod day12;
#[allow(dead_code)]
mod day13;
mod day14;
fn main() {
day13::day13();
day14::day14();
}
pub fn input(day: u8) -> String {