diff --git a/Cargo.lock b/Cargo.lock index 5ad0563..348a058 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,11 +8,21 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + [[package]] name = "aoc2023" version = "0.1.0" dependencies = [ "ureq", + "z3", ] [[package]] @@ -21,6 +31,32 @@ version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" +[[package]] +name = "bindgen" +version = "0.66.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7" +dependencies = [ + "bitflags", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "peeking_take_while", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn", +] + +[[package]] +name = "bitflags" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" + [[package]] name = "cc" version = "1.0.83" @@ -30,12 +66,41 @@ dependencies = [ "libc", ] +[[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 = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "clang-sys" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "cmake" +version = "0.1.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" +dependencies = [ + "cc", +] + [[package]] name = "crc32fast" version = "1.3.2" @@ -75,6 +140,12 @@ dependencies = [ "wasi", ] +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "idna" version = "0.5.0" @@ -85,18 +156,52 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[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.150" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" +[[package]] +name = "libloading" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" +dependencies = [ + "cfg-if", + "winapi", +] + [[package]] name = "log" version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +[[package]] +name = "memchr" +version = "2.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" + +[[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.7.1" @@ -106,18 +211,81 @@ dependencies = [ "adler", ] +[[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 = "once_cell" version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + [[package]] name = "percent-encoding" version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" +[[package]] +name = "proc-macro2" +version = "1.0.71" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75cb1540fadbd5b8fbccc4dddad2734eba435053f725621c070711a14bb5f4b8" +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 = "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 = "ring" version = "0.17.6" @@ -132,6 +300,12 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustls" version = "0.21.9" @@ -164,12 +338,29 @@ dependencies = [ "untrusted", ] +[[package]] +name = "shlex" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380" + [[package]] name = "spin" version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +[[package]] +name = "syn" +version = "2.0.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b7d0a2c048d661a1a59fcd7355baa232f7ed34e0ee4df2eef3c1c1c0d3852d8" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "tinyvec" version = "1.6.0" @@ -191,6 +382,12 @@ version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + [[package]] name = "unicode-normalization" version = "0.1.22" @@ -245,6 +442,28 @@ version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10" +[[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-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + [[package]] name = "windows-sys" version = "0.48.0" @@ -310,3 +529,23 @@ name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "z3" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a7ff5718c079e7b813378d67a5bed32ccc2086f151d6185074a7e24f4a565e8" +dependencies = [ + "log", + "z3-sys", +] + +[[package]] +name = "z3-sys" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7cf70fdbc0de3f42b404f49b0d4686a82562254ea29ff0a155eef2f5430f4b0" +dependencies = [ + "bindgen", + "cmake", +] diff --git a/Cargo.toml b/Cargo.toml index 2248a86..86f3d1c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ default-run = "main" [dependencies] ureq = { version = "2.9.1" } +z3 = { version = "0.12.1", features = ["static-link-z3"] } [[bin]] diff --git a/src/day24/1.rs b/src/day24/1.rs index b51073e..45bc21a 100644 --- a/src/day24/1.rs +++ b/src/day24/1.rs @@ -1 +1,93 @@ -const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; +#![feature(test)] + +use std::ops::RangeInclusive; + +extern crate test; + +const INPUTS: [&str; 1] = [include_str!("./input.txt")]; + +fn process(data: &str) -> i64 { + let mut answer = 0; + + let mut stones = vec![]; + for line in data.lines() { + let (a, b) = line.split_once(" @ ").unwrap(); + + let mut pos = a + .split(',') + .map(|x| x.trim()) + .map(|x| x.parse::().unwrap()); + + let mut vel = b + .split(',') + .map(|x| x.trim()) + .map(|x| x.parse::().unwrap()); + + stones.push(( + (pos.next().unwrap(), pos.next().unwrap()), + (vel.next().unwrap(), vel.next().unwrap()), + )); + } + + for i in 0..stones.len() { + let a = stones[i]; + + let x1 = a.0 .0; + let y1 = a.0 .1; + let x2 = a.0 .0 + a.1 .0; + let y2 = a.0 .1 + a.1 .1; + + let m1 = (y2 - y1) as f64 / (x2 - x1) as f64; + let c1 = y1 as f64 - m1 * x1 as f64; + + for b in stones.iter().skip(i + 1) { + let x3 = b.0 .0; + let y3 = b.0 .1; + let x4 = b.0 .0 + b.1 .0; + let y4 = b.0 .1 + b.1 .1; + + let m2 = (y4 - y3) as f64 / (x4 - x3) as f64; + let c2 = y3 as f64 - m2 * x3 as f64; + + // parallel or coincidental + if m1 == m2 { + continue; + } + + // y = m1 * x + c1; + // y = m2 * x + c2; + // x if y is equal + // (c1 - c2) / (m1 - m2) + // put this back in x and then y is + // y = m1 * i_x + c1 + let i_x = (c2 - c1) / (m1 - m2); + let i_y = m1 * i_x + c1; + + if (i_x - x1 as f64).signum() as i64 != a.1 .0.signum() + || (i_x - x3 as f64).signum() as i64 != b.1 .0.signum() + { + continue; + } + + const LOOKUP_RANGE: RangeInclusive = 200000000000000.0..=400000000000000.0; + + answer += (LOOKUP_RANGE.contains(&i_x) && LOOKUP_RANGE.contains(&i_y)) as i64 + } + } + + answer +} + +fn main() { + for input in INPUTS.iter() { + println!("answer = {}", process(input)); + } +} + +#[bench] +fn part1(b: &mut test::Bencher) { + b.iter(|| { + let v = process(INPUTS[INPUTS.len() - 1]); + test::black_box(v); + }); +} diff --git a/src/day24/2.rs b/src/day24/2.rs index b51073e..1ebfef6 100644 --- a/src/day24/2.rs +++ b/src/day24/2.rs @@ -1 +1,84 @@ -const INPUTS: [&'static str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; +#![feature(test)] + +use z3::{ + ast::{Ast, Int}, + Config, Context, SatResult, Solver, +}; + +extern crate test; + +const INPUTS: [&str; 2] = [include_str!("./sample.txt"), include_str!("./input.txt")]; + +fn process(data: &str) -> i64 { + let config = Config::new(); + let ctx = Context::new(&config); + let solver = Solver::new(&ctx); + + let x = Int::new_const(&ctx, "X"); + let v_x = Int::new_const(&ctx, "V_X"); + let y = Int::new_const(&ctx, "Y"); + let v_y = Int::new_const(&ctx, "V_Y"); + let z = Int::new_const(&ctx, "Z"); + let v_z = Int::new_const(&ctx, "V_Z"); + let zero = Int::from_i64(&ctx, 0); + + let mut i = 0; + for line in data.lines() { + i += 1; + let (a, b) = line.split_once(" @ ").unwrap(); + + let pos: Vec = a + .split(',') + .map(|x| x.trim()) + .map(|x| x.parse::().unwrap()) + .collect(); + let vel: Vec = b + .split(',') + .map(|x| x.trim()) + .map(|x| x.parse::().unwrap()) + .collect(); + + let s_x = Int::from_i64(&ctx, pos[0]); + let s_y = Int::from_i64(&ctx, pos[1]); + let s_z = Int::from_i64(&ctx, pos[2]); + + let s_vx = Int::from_i64(&ctx, vel[0]); + let s_vy = Int::from_i64(&ctx, vel[1]); + let s_vz = Int::from_i64(&ctx, vel[2]); + + let t = Int::new_const(&ctx, i); + + // For every stone, + // X + V_X * t == sx + s_vx * t; + // Y + V_Y * t == sy + s_vy * t; + // Z + V_Z * t == sz + s_vz * t; + + solver.assert(&t.ge(&zero)); + solver.assert(&((&x + &v_x * &t)._eq(&(&s_x + &s_vx * &t)))); + solver.assert(&((&y + &v_y * &t)._eq(&(&s_y + &s_vy * &t)))); + solver.assert(&((&z + &v_z * &t)._eq(&(&s_z + &s_vz * &t)))); + } + + let result = solver.check(); + if result != SatResult::Sat { + unreachable!(); + } + let model = solver.get_model().unwrap(); + let result = model.eval(&(&x + &y + &z), true).unwrap(); + + result.as_i64().unwrap() +} + +fn main() { + for input in INPUTS.iter() { + println!("answer = {}", process(input)); + } +} + +#[bench] +fn part1(b: &mut test::Bencher) { + b.iter(|| { + let v = process(INPUTS[INPUTS.len() - 1]); + test::black_box(v); + }); +} diff --git a/src/day24/input.txt b/src/day24/input.txt new file mode 100644 index 0000000..e8c1ec2 --- /dev/null +++ b/src/day24/input.txt @@ -0,0 +1,300 @@ +275325627102914, 177556324137106, 279758114394131 @ 249, 405, -531 +284428334220238, 231958436807561, 189800593445547 @ 237, 140, -111 +208260774362545, 354915461185166, 308973039318009 @ 128, -159, -65 +216164836660573, 46115124669763, 85595839318699 @ 302, 688, 387 +387160819800868, 326055172786046, 424274962581514 @ -169, -60, -78 +251635755786500, 217097084907301, 177350631711689 @ 131, 118, 125 +247915698072060, 256017235539750, 406425467500058 @ -10, 21, -52 +142886026994668, 181226615885678, 74604768684426 @ 254, 156, 358 +242632083944780, 325377174991042, 369509461030046 @ 5, -64, -31 +437035912651352, 252498326441926, 562928520216470 @ -224, 25, -225 +234535071679495, 174981427949087, 261677448496553 @ 240, 272, -175 +290620962742745, 259352652801649, 337506708741698 @ 20, 8, -264 +370765834096665, 330920771305076, 364503409652079 @ -172, -145, -255 +189479107042940, 250724935024242, 383855760393546 @ 55, 27, -24 +66769769721378, 164951301085592, 52536619621894 @ 162, 114, 342 +277670947497460, 176140935580014, 370791351808746 @ 5, 164, -182 +334481227003927, 239981377044292, 154570476022731 @ 92, 211, -221 +234817161058231, 138709258194428, 266737850522698 @ 114, 263, -32 +328708952423036, 157641505054102, 213511104776042 @ -6, 579, -266 +313747174306592, 272562646289128, 166164215907011 @ 111, -109, -27 +334521631655416, 138237118452190, 195327553393202 @ -73, 433, 8 +288721715387732, 391977000041254, 174137866811354 @ -22, -213, 182 +365898022728404, 416679045476518, 266782780564778 @ -142, -141, 125 +293410982678177, 562532497428055, 412529707779104 @ -16, -582, -298 +328443661751908, 514376863639812, 440679239228909 @ -93, -381, -223 +302810152693700, 257967093398566, 188701731581114 @ -15, 12, 112 +294990125561517, 347850830570574, 378112110922674 @ -66, -79, -8 +137983158051812, 162654670932032, 303594250841134 @ 211, 168, -18 +37387660420460, 234316020446107, 107540645055690 @ 235, 46, 288 +364153984909940, 225498536365096, 279311207421029 @ -173, 111, -231 +147145086993025, 346629370163251, 400568806399389 @ 126, -92, -75 +326247735716400, 544391581704186, 142984796826154 @ -70, -678, 220 +235192096408592, 179771957454298, 322420492023248 @ 41, 131, -21 +350507930374574, 367809581387920, 192810883536693 @ -131, -461, -29 +338309983006285, 258455909106939, 153970399616917 @ -40, -22, 15 +338508254765178, 393833211968320, 527130712835758 @ -114, -122, -150 +190698039509103, 213630523957166, 478005918373987 @ 38, 65, -95 +213685970219903, 108836212086532, 270141329510660 @ 88, 251, 38 +241379659881636, 305389014936636, 227175207565734 @ 99, -85, 52 +301356853518858, 279136920552982, 278450541689415 @ -39, -23, -11 +241856278716572, 137000754643438, 216493263202754 @ 264, 444, -73 +241117570334927, 365404746624486, 261115525552232 @ 28, -135, 74 +281971046691967, 180006621695636, 289995505163653 @ 162, 335, -449 +372147500903132, 449358924234892, 450867634413914 @ -153, -214, -128 +341189658484942, 355846814217958, 327373108296600 @ -103, -263, -302 +361041391927927, 268166194619520, 210453291796322 @ -154, -13, 56 +372148079884052, 241790159004634, 284487457698146 @ -153, 38, 74 +311787382570736, 318682133535468, 170208959012711 @ 79, -337, 5 +208687107521475, 49223813566626, 40428558498864 @ 38, 261, 366 +308624438144228, 265503293170942, 231936047772950 @ -13, -11, -34 +224910004031716, 367405915954950, 164947513698186 @ 9, -99, 225 +196667506610732, 156057590126002, 6069593443286 @ 101, 168, 443 +190012329645581, 393895664209854, 238968790785515 @ 82, -159, 119 +254448135501819, 171812483356692, 81050909033697 @ 126, 239, 379 +225959490083012, 315343299181748, 233616996183139 @ 67, -73, 97 +207038727474889, 133110300792437, 458643216900053 @ 38, 162, -115 +329911419275910, 199753245006458, 114428975609316 @ 120, 699, 361 +305397226531016, 194868524262862, 311014470004202 @ -31, 149, -136 +254868442600580, 223939134169144, 57209254128206 @ 195, 122, 490 +317754495021180, 237754872506246, 169770788802764 @ 215, 185, -253 +287727504722884, 171008786715561, 369697251624885 @ -61, 110, 13 +341873367046436, 252949011916180, 128154112690124 @ -109, 24, 257 +209321362635443, 330581864788817, 217849966181297 @ 88, -94, 125 +258804685099616, 277839982451718, 315415884401284 @ -11, -7, 27 +199871420643324, 347659623630176, 221122870029600 @ 71, -100, 141 +312613173684107, 218401028038600, 207500299329017 @ 44, 183, -127 +171247075527536, 190350897184116, 71675887170066 @ 61, 90, 324 +169729385444732, 353045797957402, 186613812099866 @ 73, -86, 200 +296921508959837, 283585262955109, 313184421945782 @ -26, -34, -92 +327478692390694, 231208095033796, 184633703129352 @ 12, 160, -129 +353717120359148, 345154040934886, 301300342883478 @ -137, -215, -194 +211913618583800, 244268083478884, 156143745309158 @ 25, 34, 234 +317608640543618, 419912525447052, 28563341482191 @ 13, -709, 679 +303743226002695, 281993580499986, 144142829716839 @ 164, -163, 127 +320010583165868, 266123648912374, 140776331555402 @ 178, -117, 70 +336419814147420, 261725334225370, 160292000643774 @ 15, -77, -158 +227379215575199, 282708816988561, 254319988981508 @ 16, -10, 118 +410120237268590, 492787037864554, 473474616297170 @ -220, -349, -276 +307286090152268, 414715322884874, 427914290112682 @ -83, -138, -36 +295681395847085, 155864437207556, 274482255100237 @ -20, 215, -29 +379196817290080, 345731205433241, 372717243509424 @ -177, -136, -162 +333885833951784, 426696526574594, 130162196354804 @ -73, -571, 242 +171164023494995, 241080980272546, 451545423974219 @ 62, 37, -75 +106074225183437, 270978182673946, 85358110923875 @ 138, 5, 311 +278053693010996, 294943465948654, 327555936751850 @ -43, -24, 34 +352231646575532, 176569425864529, 158768159876069 @ -133, 218, 177 +246127460675865, 273246289635111, 247447493750004 @ 138, -28, -50 +244579639799972, 246692510062230, 348546396431920 @ 19, 33, -41 +477582396603836, 346037356846075, 306582214002710 @ -261, -74, 76 +299083967355120, 292498620265430, 229966056668682 @ -55, -31, 120 +176681221115745, 311075446093086, 351708414659284 @ 134, -63, -74 +354222521158564, 376749018751110, 342335851111066 @ -136, -241, -201 +229813603057912, 234809870487771, 283116856442874 @ 111, 60, -48 +406920111300250, 240413238780426, 376043892015064 @ -192, 39, -23 +311531991927510, 412623203490271, 187848819074639 @ 53, -734, -43 +303801597702992, 302617083822430, 209321475103514 @ -22, -89, 72 +225440876458244, 382581548064862, 281743940398646 @ 67, -177, 23 +234827874729668, 299918491173670, 250585775436026 @ 181, -102, -74 +337155612435834, 341612898161372, 227348951282112 @ -108, -102, 121 +415356975674820, 294301069251974, 285546064537722 @ -190, -16, 111 +348225908097476, 255809400227590, 135006022806266 @ -111, -29, 50 +219698749811152, 251387720563614, 300201376984546 @ 108, 27, -50 +287256859780250, 244254663128026, 328309779755204 @ -50, 35, 21 +260258225660277, 236794262976870, 240155810530800 @ 56, 57, 30 +217977977344664, 147308342104732, 379795313839421 @ 47, 163, -67 +347504765845068, 389920811122510, 389920524779754 @ -123, -149, -68 +286716702094967, 286633697338049, 82895291971664 @ 118, -108, 422 +342181393917667, 332063801020159, 188606674398109 @ -106, -194, 87 +345154458686632, 248417301419140, 146484577012702 @ -99, 52, 106 +222085789777459, 236512495620760, 327433427826898 @ 18, 43, 40 +321784617384290, 250071684908574, 296112020977658 @ -80, 29, -16 +288286653234021, 274184123629358, 222077888946534 @ 32, -31, 12 +300338424435035, 250744876434751, 176101470800174 @ 14, 30, 116 +287634735314180, 305306575857826, 340308028154954 @ -61, -30, 44 +209079620844704, 168621628540832, 247524203359914 @ 97, 158, 72 +319367647724274, 271326456316344, 191488916494328 @ 6, -58, -37 +285032377146372, 350577886345622, 244493686373810 @ -61, -73, 149 +341870999756132, 259711661320294, 166076432739538 @ -89, -11, 49 +256392343712288, 250625760968750, 303032681474386 @ -26, 27, 78 +280233963659612, 303938258779486, 65469391317018 @ 136, -170, 484 +245993918700500, 195486202478426, 401768522396814 @ 7, 98, -87 +249856474410000, 231429397216176, 277032049695564 @ 21, 56, 43 +325748302517502, 301044086685316, 158867750764194 @ 12, -260, 52 +321908410838453, 298364864494326, 146964425540527 @ 112, -375, 49 +263847806151284, 310183653799254, 372798540850042 @ -26, -42, -20 +245381277136603, 236544009903788, 349105439347920 @ 18, 47, -42 +330527801785316, 273108246122782, 127553991071330 @ 119, -246, 191 +320261705743364, 301136512695718, 246592124822186 @ -93, -29, 133 +334404997003140, 268645597836422, 131592107246522 @ 65, -184, 140 +205914140312345, 321860283939616, 381945799125329 @ 36, -53, -21 +119043963500960, 128050256812306, 356148143741279 @ 119, 157, 23 +135927000217100, 361881695419276, 383165995650314 @ 103, -92, -8 +315902428580450, 358283377366376, 223492003050314 @ -8, -348, -88 +231570575783570, 318185504466292, 414876910373252 @ 70, -84, -215 +334046048927216, 257480890983496, 145219548293276 @ 41, -30, 9 +281394098779603, 184808090587029, 465842878850600 @ -46, 104, -130 +300693272969300, 467755117987126, 248211785285114 @ -9, -491, -32 +243100431088484, 298329203651014, 356277076272890 @ -14, -23, 26 +255632291594886, 418701010581999, 123759705083646 @ 33, -256, 268 +210207111103595, 293647133414046, 427952442518608 @ 10, -15, -26 +315018153329816, 256283457698002, 241256320352054 @ -17, 13, -108 +373102627048850, 292528813799176, 379723908988434 @ -170, -50, -212 +340073766334217, 281987459061034, 383519453857274 @ -114, -11, -48 +323834614668146, 320478341735956, 254764146296030 @ -86, -80, 66 +296728054380092, 375837640502791, 163681595397182 @ -21, -220, 188 +286698550927916, 87535917602401, 223170637969427 @ 187, 850, -237 +482185920690648, 391790683942546, 491292424383516 @ -297, -155, -206 +376234083918820, 303904818939286, 276503463782634 @ -247, -206, -425 +379183368886655, 207805821037211, 300163852195174 @ -158, 74, 76 +185822780025860, 282472127483356, 244477736980484 @ 131, -22, 79 +373357415223548, 391711582761466, 329856757988138 @ -159, -170, -20 +261574291585469, 314196054634768, 414772823819828 @ 14, -73, -194 +195877516308755, 120633751465041, 318809581553269 @ 76, 198, 13 +330478915144162, 146639905203796, 404324520067316 @ -96, 190, -169 +386537287135260, 186019335753077, 186936497452644 @ -165, 96, 202 +259110719482970, 412695250980016, 226728794656154 @ 80, -340, 32 +300864540272625, 284833953249301, 89058203768939 @ -40, -32, 329 +137214130986014, 103500175095633, 382355910679937 @ 121, 198, -31 +277516414962622, 173874414689722, 501409404045300 @ -54, 103, -105 +349084334634500, 211003927797606, 272760721405594 @ -125, 96, 13 +40684667846753, 153541424014705, 309700169175686 @ 196, 128, 76 +280784208267875, 250474618994026, 261535571343389 @ 10, 29, -5 +195470064236732, 268725185990986, 321525098348054 @ 159, -5, -98 +334968726054831, 505093427341266, 544862087966384 @ -106, -315, -298 +156439156044675, 160028640718810, 219198305860379 @ 200, 181, 107 +299377215767799, 157637412574176, 372585530498116 @ 6, 275, -390 +328390016569082, 280540627008833, 174179337525786 @ 13, -162, -80 +405355365101693, 336387040573999, 467650539524747 @ -288, -218, -731 +328478225741220, 225452808519496, 243742602130164 @ -93, 67, 82 +201913979133584, 304440804854014, 353211187933966 @ 28, -29, 31 +379128262567006, 351954087873670, 250893519940564 @ -154, -71, 147 +333023400242195, 233225205171160, 112730659904101 @ 40, 223, 361 +278130236356697, 159188827336870, 375079031268185 @ -52, 121, 11 +409771663516894, 397302902319537, 408698400222078 @ -283, -352, -476 +275545930911023, 408807227862823, 244912880986310 @ 106, -466, -116 +335915298513102, 277917628722764, 223377296353652 @ -82, -58, -61 +320475108339012, 227835200325126, 112145158282514 @ 107, 225, 347 +335149387752852, 200122146783318, 91842132879026 @ -9, 461, 518 +280035921782524, 389753098330610, 282226109292502 @ -43, -138, 81 +325587489900676, 242657115498214, 150688598036666 @ 183, 154, -112 +285289947541614, 285294032482635, 248084092267820 @ 17, -48, -10 +230113691050109, 329584174157655, 169962370466571 @ 142, -148, 163 +255432313813788, 159474842673702, 232016351814202 @ 24, 173, 96 +238298831590466, 321620905264272, 451856570425612 @ -8, -48, -77 +215200562980374, 56386886272502, 487217093969278 @ 17, 233, -116 +162395067100300, 170355048726878, 401427731877614 @ 75, 113, -28 +314822230720202, 419028087327700, 487121870033588 @ -82, -184, -187 +239693785261884, 281909936414752, 200340783661268 @ 87, -32, 119 +208860669436926, 334380758674086, 226817462075220 @ 12, -55, 169 +296956857166940, 276824482593454, 270825932649986 @ -35, -17, 14 +329777311382727, 286096046662534, 117369103674887 @ 206, -551, 341 +400786600605144, 315123606350030, 308541469371462 @ -196, -61, 15 +349600091447493, 257140137758863, 178642836818537 @ -126, 16, 161 +388067682593330, 301759102498993, 321626481455759 @ -235, -114, -293 +251315080533458, 278634661696660, 35563396282990 @ 178, -56, 538 +198571772120780, 392748668784256, 183651299616080 @ 95, -180, 181 +285191191077444, 387182168826402, 207794786068242 @ 51, -346, 34 +264691875610794, 355370885981772, 96445694879525 @ 149, -309, 353 +260666644807234, 251030812917822, 207610250117424 @ 116, 29, 37 +249153700279648, 171229437056956, 433225569105310 @ 41, 160, -246 +247902039565320, 286744641696110, 356448085275486 @ 5, -19, -30 +262300560012344, 378580414100530, 376832865313226 @ -19, -129, -40 +327960724844075, 227333678256811, 190826217539624 @ -10, 162, -106 +264202500102932, 312203345646334, 245839232050562 @ -7, -58, 99 +216967762420420, 243415312102208, 374066774935742 @ 35, 36, -34 +225464507562464, 9726858818530, 201076490195036 @ 41, 351, 165 +254846318056027, 281880521724948, 249672195348532 @ 138, -57, -86 +186295093603832, 59562929664838, 202286015162541 @ 199, 409, 111 +186029904723842, 30151376563756, 317388549357812 @ 73, 295, 34 +307434093981220, 312311829936486, 170559904129434 @ 141, -357, -42 +347885749070876, 207285015458554, 137175207164030 @ -107, 704, 35 +352761067144174, 555040887237958, 335169563638788 @ -132, -551, -135 +304003604370648, 230799019710445, 272616130976325 @ 143, 154, -627 +377181731950175, 445117833340951, 303857651698589 @ -208, -544, -267 +352643412440170, 259616482053266, 173387315041754 @ -148, -21, -64 +230527745846325, 210946338731601, 317336231338764 @ 186, 134, -242 +410974041024260, 514498083491910, 447346284229050 @ -185, -229, -44 +272412180156019, 208379712412409, 189927599942554 @ 54, 128, 112 +295434874992370, 252498326441926, 207972958550510 @ 20, 25, 38 +335957076272514, 246295997949795, 120912096324498 @ 93, 128, 280 +392628915171716, 386533988408044, 211204527934322 @ -189, -172, 140 +238007057118248, 293174512574638, 360757541280350 @ 17, -27, -34 +245380468822654, 269976506073136, 262384479601408 @ 53, -5, 30 +208567810095200, 306732774509726, 282248273141039 @ 103, -63, 11 +310381559177851, 331062643087459, 195323084292907 @ 42, -314, -47 +235708863732664, 518098205827346, 161035603618914 @ 18, -310, 222 +282183870219638, 148517372060687, 125283392460899 @ 133, 426, 257 +353408840662948, 252228044815148, 228425354780402 @ -141, 26, -124 +311950351978492, 471986688212259, 482123947806106 @ -69, -306, -272 +258261234136568, 450713606582683, 25047703696751 @ 23, -298, 429 +288323146304944, 300956629531200, 192449269821208 @ 117, -168, -11 +221337267596260, 322267878439734, 349373211752250 @ 5, -46, 40 +401143984464870, 355873916819375, 458294135907137 @ -195, -114, -181 +340472189329328, 180730448898826, 330956033002166 @ -113, 125, -20 +222997655392620, 421814724281022, 443815481780550 @ 15, -163, -86 +293301297256670, 219028504015228, 228975402662129 @ -55, 67, 137 +273666475791288, 226509739948657, 282421150809118 @ 23, 76, -44 +320326086631852, 290711340911198, 196638013706530 @ 21, -169, -110 +298374208292726, 285759807160724, 300787718387536 @ -32, -36, -57 +302335047949145, 183566044898030, 155309979740199 @ 130, 401, 87 +284467067156055, 440908674773813, 193493097447000 @ -30, -252, 166 +344838075370940, 242307304209382, 132434104661570 @ -115, 49, 246 +140901227437165, 1131726420376, 221295940841289 @ 198, 415, 117 +322918245372179, 384867954474844, 188604765740315 @ 28, -749, -121 +297948628259048, 496863648944086, 80666276825954 @ -12, -515, 362 +331838378700713, 185274294128593, 287166182511287 @ -76, 216, -199 +323270060688900, 345945998124998, 278860901644474 @ -75, -156, -33 +237158947319675, 248660884591132, 182153326547219 @ 50, 31, 177 +117654570978948, 209105245756510, 70768569776662 @ 99, 67, 321 +185257339970739, 269947355459368, 397670123352479 @ 44, 7, -13 +251358345165730, 324665210972710, 392771385947283 @ 5, -71, -89 +326550414725036, 306890546913046, 309824022922694 @ -67, -115, -213 +289528512876515, 285050576843806, 308939182323509 @ 36, -63, -235 +204986980766156, 231811082569738, 361080518198906 @ 77, 54, -64 +368775546413334, 232807114663092, 274642826594196 @ -148, 48, 93 +335505366596620, 243671997217304, 181335275200670 @ 15, 116, -346 +270200513741972, 296580461646574, 314736528842314 @ -23, -32, 22 +265822841603420, 244866022914077, 265019906054927 @ -5, 36, 65 +206625760792148, 44495432240182, 45482806486610 @ 301, 647, 499 +311539637734608, 281748264724400, 109606542014720 @ -39, -42, 299 +347268406128434, 184098352713440, 275747753591924 @ -122, 138, 17 +276558704773394, 445900006071542, 302291091264360 @ -38, -207, 55 +402057911872010, 256451578474576, 431328789936074 @ -192, 20, -120 +205446048698663, 197157168657123, 146266261041394 @ 106, 114, 232 +357605395843720, 198328723040456, 160347253247034 @ -139, 114, 208 +339522556626996, 262293318547174, 194156629072442 @ -84, -17, -40 +277295150236338, 360648266574222, 441182015622672 @ -48, -91, -71 +98329743871286, 201497392727374, 91643285909492 @ 229, 97, 314 +272987089084174, 359992337638890, 141615476247030 @ 161, -379, 196 +261458820655700, 182397915258886, 239312736530642 @ 225, 305, -199 +338605255141296, 520463359196714, 419299090454542 @ -111, -333, -126 +244688577521344, 314515607895286, 307445674936394 @ -24, -35, 92 +338351117624276, 308400498370176, 218887218419182 @ -101, -100, 54 +230514744365880, 198829985583498, 287391256952382 @ 65, 111, 6 +229813454835893, 224231817356707, 322017102376283 @ 48, 66, -19 +273661485268800, 237724778628026, 305674400676014 @ -28, 44, 35 +293056386127287, 253757381464560, 255483190486835 @ -36, 23, 59 +303461936059110, 231441834791746, 110614912231579 @ 57, 109, 315 +336311884673570, 241467574202941, 328655859487769 @ -103, 44, -85 +289923312835478, 199910751509462, 361623434245070 @ -26, 113, -130 +340755060112644, 344901215668766, 209371792713418 @ -93, -330, -66 +307464534531381, 295369849856417, 171462763031194 @ 8, -112, 112 +352884691593970, 263899397320336, 512830597401724 @ -135, -5, -758 +342221433644104, 224787745084478, 175131640218094 @ -72, 239, -143 +324955785076869, 503667806174374, 150464372212014 @ -42, -839, 172 +336049403702140, 244265738484646, 242138453949754 @ -87, 49, -80 +339598398806870, 341349925360727, 165029135383412 @ -95, -256, 134 +276133623500445, 251844059974356, 236871862102419 @ 98, 27, -81 +325248475515080, 459870300780880, 390739038625760 @ -95, -236, -67 +233150198634180, 251002402106438, 443765524873978 @ 30, 27, -159 +168279311145848, 266478096299296, 381417549923396 @ 69, 10, -7 +224865693834272, 164908259210996, 490068386284683 @ 31, 135, -191 +347418483347855, 304324810915326, 205241678670779 @ -116, -255, -181 +273575549469386, 245745508256428, 199051239709541 @ 121, 47, 19 +322577448890609, 206356710517375, 199932751298954 @ -98, 72, 192 +274077567225684, 337971154419414, 413571354785074 @ -39, -73, -63 +334874007081875, 276497990753026, 173077318193639 @ 10, -203, -219 +331757977898368, 269368726421844, 264108295271296 @ -87, -12, -41 +285092233529012, 326692066854086, 137160000413898 @ -56, -55, 255 +259140723374604, 154993084146906, 238798101911134 @ 101, 270, -23 diff --git a/src/day24/sample.txt b/src/day24/sample.txt new file mode 100644 index 0000000..cbe1492 --- /dev/null +++ b/src/day24/sample.txt @@ -0,0 +1,5 @@ +19, 13, 30 @ -2, 1, -2 +18, 19, 22 @ -1, -1, -2 +20, 25, 34 @ -2, -2, -4 +12, 31, 28 @ -1, -2, -1 +20, 19, 15 @ 1, -5, -3 \ No newline at end of file