diff options
| author | mhsn <mail@mhsn.net> | 2026-01-18 11:27:51 +0000 |
|---|---|---|
| committer | mhsn <mail@mhsn.net> | 2026-01-18 11:30:32 +0000 |
| commit | 940d5ca4550b2d1231fad80f55a7186ceca66e45 (patch) | |
| tree | f9181dadd1d49d65bccea0f4678659cc26b0d328 | |
| parent | fb78659f05d5d72c819d316bebc960fc48472bbd (diff) | |
| download | aoc-940d5ca4550b2d1231fad80f55a7186ceca66e45.tar.gz aoc-940d5ca4550b2d1231fad80f55a7186ceca66e45.zip | |
25-09 rust
| -rw-r--r-- | 2025/09/rust/Cargo.lock | 7 | ||||
| -rw-r--r-- | 2025/09/rust/Cargo.toml | 6 | ||||
| -rw-r--r-- | 2025/09/rust/src/main.rs | 27 |
3 files changed, 40 insertions, 0 deletions
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::<Vec<(u64, u64)>>(); + + 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) +} |
