From f07e8b1ea25d4449f59b8af27efcf73ec8c43e9c Mon Sep 17 00:00:00 2001 From: endernon Date: Sun, 1 Dec 2024 20:19:07 +0000 Subject: [PATCH] ye --- 2024/day1/part2/Cargo.lock | 96 +++++++++++++++++++++++++++++++++++++ 2024/day1/part2/Cargo.toml | 8 ++++ 2024/day1/part2/src/main.rs | 17 +++++++ 3 files changed, 121 insertions(+) create mode 100644 2024/day1/part2/Cargo.lock create mode 100644 2024/day1/part2/Cargo.toml create mode 100644 2024/day1/part2/src/main.rs diff --git a/2024/day1/part2/Cargo.lock b/2024/day1/part2/Cargo.lock new file mode 100644 index 0000000..7e406fc --- /dev/null +++ b/2024/day1/part2/Cargo.lock @@ -0,0 +1,96 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "itoa" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "part2" +version = "0.1.0" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "proc-macro2" +version = "1.0.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "serde" +version = "1.0.215" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.215" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.133" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "syn" +version = "2.0.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" diff --git a/2024/day1/part2/Cargo.toml b/2024/day1/part2/Cargo.toml new file mode 100644 index 0000000..9817053 --- /dev/null +++ b/2024/day1/part2/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "part2" +version = "0.1.0" +edition = "2021" + +[dependencies] +serde = "1.0.215" +serde_json = "1.0.133" diff --git a/2024/day1/part2/src/main.rs b/2024/day1/part2/src/main.rs new file mode 100644 index 0000000..0b92783 --- /dev/null +++ b/2024/day1/part2/src/main.rs @@ -0,0 +1,17 @@ +fn main() { + let mut list1: Vec = serde_json::from_reader(std::fs::File::open("l1.json").unwrap()).unwrap(); + let mut list2: Vec = serde_json::from_reader(std::fs::File::open("l2.json").unwrap()).unwrap(); + + let mut simScoreTotal: i64 = 0; + + for i in &list1 { + let mut totalsRight: i32 = 0; + for j in &list2 { + if i==j { + totalsRight += 1; + } + } + simScoreTotal += (totalsRight*i) as i64; + } + println!("{simScoreTotal}") +}