commit 9f2c05436e1773f40b0e9ea3a30fea950eadaf7d Author: Ishan Jain Date: Fri Dec 1 10:36:35 2023 +0530 initial commit, setup project diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5b605c0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target +.aoc_token diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..5ad0563 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,312 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aoc2023" +version = "0.1.0" +dependencies = [ + "ureq", +] + +[[package]] +name = "base64" +version = "0.21.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" + +[[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 = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "flate2" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[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 = "getrandom" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[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 = "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 = "miniz_oxide" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +dependencies = [ + "adler", +] + +[[package]] +name = "once_cell" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "ring" +version = "0.17.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "684d5e6e18f669ccebf64a92236bb7db9a34f07be010e3627368182027180866" +dependencies = [ + "cc", + "getrandom", + "libc", + "spin", + "untrusted", + "windows-sys", +] + +[[package]] +name = "rustls" +version = "0.21.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "629648aced5775d558af50b2b4c7b02983a04b312126d45eeead26e7caa498b9" +dependencies = [ + "log", + "ring", + "rustls-webpki", + "sct", +] + +[[package]] +name = "rustls-webpki" +version = "0.101.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "sct" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + +[[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 = "unicode-bidi" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "ureq" +version = "2.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cdd25c339e200129fe4de81451814e5228c9b771d57378817d6117cc2b3f97" +dependencies = [ + "base64", + "flate2", + "log", + "once_cell", + "rustls", + "rustls-webpki", + "url", + "webpki-roots", +] + +[[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 = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "webpki-roots" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10" + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[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_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[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_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[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_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..7f9471e --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,263 @@ +[package] +name = "aoc2023" +version = "0.1.0" +edition = "2021" +default-run = "main" + + +[dependencies] +ureq = { version = "2.9.1" } + + +[[bin]] +name = "main" +path = "src/main.rs" + +[[bin]] +name = "d1-1" +path = "src/day1/1.rs" + + +[[bin]] +name = "d1-2" +path = "src/day1/2.rs" + + +[[bin]] +name = "d2-1" +path = "src/day2/1.rs" + + +[[bin]] +name = "d2-2" +path = "src/day2/2.rs" + + +[[bin]] +name = "d3-1" +path = "src/day3/1.rs" + + +[[bin]] +name = "d3-2" +path = "src/day3/2.rs" + + +[[bin]] +name = "d4-1" +path = "src/day4/1.rs" + + +[[bin]] +name = "d4-2" +path = "src/day4/2.rs" + + +[[bin]] +name = "d5-1" +path = "src/day5/1.rs" + + +[[bin]] +name = "d5-2" +path = "src/day5/2.rs" + + +[[bin]] +name = "d6-1" +path = "src/day6/1.rs" + + +[[bin]] +name = "d6-2" +path = "src/day6/2.rs" + + +[[bin]] +name = "d7-1" +path = "src/day7/1.rs" + + +[[bin]] +name = "d7-2" +path = "src/day7/2.rs" + + +[[bin]] +name = "d8-1" +path = "src/day8/1.rs" + + +[[bin]] +name = "d8-2" +path = "src/day8/2.rs" + + +[[bin]] +name = "d9-1" +path = "src/day9/1.rs" + + +[[bin]] +name = "d9-2" +path = "src/day9/2.rs" + + +[[bin]] +name = "d10-1" +path = "src/day10/1.rs" + + +[[bin]] +name = "d10-2" +path = "src/day10/2.rs" + + +[[bin]] +name = "d11-1" +path = "src/day11/1.rs" + + +[[bin]] +name = "d11-2" +path = "src/day11/2.rs" + + +[[bin]] +name = "d12-1" +path = "src/day12/1.rs" + + +[[bin]] +name = "d12-2" +path = "src/day12/2.rs" + + +[[bin]] +name = "d13-1" +path = "src/day13/1.rs" + + +[[bin]] +name = "d13-2" +path = "src/day13/2.rs" + + +[[bin]] +name = "d14-1" +path = "src/day14/1.rs" + + +[[bin]] +name = "d14-2" +path = "src/day14/2.rs" + + +[[bin]] +name = "d15-1" +path = "src/day15/1.rs" + + +[[bin]] +name = "d15-2" +path = "src/day15/2.rs" + + +[[bin]] +name = "d16-1" +path = "src/day16/1.rs" + + +[[bin]] +name = "d16-2" +path = "src/day16/2.rs" + + +[[bin]] +name = "d17-1" +path = "src/day17/1.rs" + + +[[bin]] +name = "d17-2" +path = "src/day17/2.rs" + + +[[bin]] +name = "d18-1" +path = "src/day18/1.rs" + + +[[bin]] +name = "d18-2" +path = "src/day18/2.rs" + + +[[bin]] +name = "d19-1" +path = "src/day19/1.rs" + + +[[bin]] +name = "d19-2" +path = "src/day19/2.rs" + + +[[bin]] +name = "d20-1" +path = "src/day20/1.rs" + + +[[bin]] +name = "d20-2" +path = "src/day20/2.rs" + + +[[bin]] +name = "d21-1" +path = "src/day21/1.rs" + + +[[bin]] +name = "d21-2" +path = "src/day21/2.rs" + + +[[bin]] +name = "d22-1" +path = "src/day22/1.rs" + + +[[bin]] +name = "d22-2" +path = "src/day22/2.rs" + + +[[bin]] +name = "d23-1" +path = "src/day23/1.rs" + + +[[bin]] +name = "d23-2" +path = "src/day23/2.rs" + + +[[bin]] +name = "d24-1" +path = "src/day24/1.rs" + + +[[bin]] +name = "d24-2" +path = "src/day24/2.rs" + + +[[bin]] +name = "d25-1" +path = "src/day25/1.rs" + + +[[bin]] +name = "d25-2" +path = "src/day25/2.rs" diff --git a/src/day1/1.rs b/src/day1/1.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day1/1.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day1/2.rs b/src/day1/2.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day1/2.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day10/1.rs b/src/day10/1.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day10/1.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day10/2.rs b/src/day10/2.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day10/2.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day11/1.rs b/src/day11/1.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day11/1.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day11/2.rs b/src/day11/2.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day11/2.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day12/1.rs b/src/day12/1.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day12/1.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day12/2.rs b/src/day12/2.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day12/2.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day13/1.rs b/src/day13/1.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day13/1.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day13/2.rs b/src/day13/2.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day13/2.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day14/1.rs b/src/day14/1.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day14/1.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day14/2.rs b/src/day14/2.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day14/2.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day15/1.rs b/src/day15/1.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day15/1.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day15/2.rs b/src/day15/2.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day15/2.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day16/1.rs b/src/day16/1.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day16/1.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day16/2.rs b/src/day16/2.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day16/2.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day17/1.rs b/src/day17/1.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day17/1.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day17/2.rs b/src/day17/2.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day17/2.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day18/1.rs b/src/day18/1.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day18/1.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day18/2.rs b/src/day18/2.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day18/2.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day19/1.rs b/src/day19/1.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day19/1.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day19/2.rs b/src/day19/2.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day19/2.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day2/1.rs b/src/day2/1.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day2/1.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day2/2.rs b/src/day2/2.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day2/2.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day20/1.rs b/src/day20/1.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day20/1.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day20/2.rs b/src/day20/2.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day20/2.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day21/1.rs b/src/day21/1.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day21/1.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day21/2.rs b/src/day21/2.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day21/2.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day22/1.rs b/src/day22/1.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day22/1.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day22/2.rs b/src/day22/2.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day22/2.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day23/1.rs b/src/day23/1.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day23/1.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day23/2.rs b/src/day23/2.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day23/2.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day24/1.rs b/src/day24/1.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day24/1.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day24/2.rs b/src/day24/2.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day24/2.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day25/1.rs b/src/day25/1.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day25/1.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day25/2.rs b/src/day25/2.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day25/2.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day3/1.rs b/src/day3/1.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day3/1.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day3/2.rs b/src/day3/2.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day3/2.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day4/1.rs b/src/day4/1.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day4/1.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day4/2.rs b/src/day4/2.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day4/2.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day5/1.rs b/src/day5/1.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day5/1.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day5/2.rs b/src/day5/2.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day5/2.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day6/1.rs b/src/day6/1.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day6/1.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day6/2.rs b/src/day6/2.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day6/2.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day7/1.rs b/src/day7/1.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day7/1.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day7/2.rs b/src/day7/2.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day7/2.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day8/1.rs b/src/day8/1.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day8/1.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day8/2.rs b/src/day8/2.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day8/2.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day9/1.rs b/src/day9/1.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day9/1.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/day9/2.rs b/src/day9/2.rs new file mode 100644 index 0000000..b51073e --- /dev/null +++ b/src/day9/2.rs @@ -0,0 +1 @@ +const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..b0b9088 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,40 @@ +use std::{env, fs::File, io}; + +const AOC_TOKEN: &str = include_str!("../.aoc_token"); + +fn main() { + let args: Vec = env::args().collect(); + assert!(args.len() == 2); + + let day: u8 = args[1].parse::().expect("error in parsing day"); + assert!((1..=25).contains(&day)); + + let request = ureq::get(&format!("https://adventofcode.com/2023/day/{}/input", day)) + .set("Cookie", AOC_TOKEN); + println!("{:?}", request); + + let response = match request.call() { + Ok(r) => r, + Err(e) => { + eprintln!("error in fetching input for day {}: {}", day, e); + + if let Some(v) = e.into_response() { + eprintln!( + "error in fetching input for day {} status code = {} response = {:?}", + day, + v.status(), + v.into_string() + ); + } + + return; + } + }; + + let mut file = + File::create(format!("./src/day{}/input.txt", day)).expect("error in creating file"); + + io::copy(&mut response.into_reader(), &mut file).expect("error in writing to file"); + + println!("Saved input for day {}", day); +}