From 940d5ca4550b2d1231fad80f55a7186ceca66e45 Mon Sep 17 00:00:00 2001 From: mhsn Date: Sun, 18 Jan 2026 11:27:51 +0000 Subject: 25-09 rust --- 2025/09/rust/Cargo.lock | 7 +++++++ 2025/09/rust/Cargo.toml | 6 ++++++ 2025/09/rust/src/main.rs | 27 +++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 2025/09/rust/Cargo.lock create mode 100644 2025/09/rust/Cargo.toml create mode 100644 2025/09/rust/src/main.rs (limited to '2025/09/rust') diff --git a/2025/09/rust/Cargo.lock b/2025/09/rust/Cargo.lock new file mode 100644 index 0000000..1a33f1f --- /dev/null +++ b/2025/09/rust/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aoc_2025-09" +version = "0.1.0" diff --git a/2025/09/rust/Cargo.toml b/2025/09/rust/Cargo.toml new file mode 100644 index 0000000..a713c42 --- /dev/null +++ b/2025/09/rust/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "aoc_2025-09" +version = "0.1.0" +edition = "2024" + +[dependencies] diff --git a/2025/09/rust/src/main.rs b/2025/09/rust/src/main.rs new file mode 100644 index 0000000..0a60ece --- /dev/null +++ b/2025/09/rust/src/main.rs @@ -0,0 +1,27 @@ +use std::io; + +fn main() { + let pts = io::stdin() + .lines() + .flatten() + .map(|line| { + let (x, y) = line.split_once(',').unwrap(); + (x.parse().unwrap(), y.parse().unwrap()) + }) + .collect::>(); + + let silver: u64 = pts + .iter() + .enumerate() + .flat_map(|(idx, p1)| pts.iter().take(idx).map(move |p2| area(*p1, *p2))) + .max() + .unwrap(); + + let gold: u64 = 0; + println!("silver: {silver}"); + println!("gold: {gold}"); +} + +fn area((x1, y1): (u64, u64), (x2, y2): (u64, u64)) -> u64 { + (x1.abs_diff(x2) + 1) * (y1.abs_diff(y2) + 1) +} -- cgit v1.2.3