summaryrefslogtreecommitdiff
path: root/2025/09/rust/src/main.rs
diff options
context:
space:
mode:
authormhsn <mail@mhsn.net>2026-01-18 11:27:51 +0000
committermhsn <mail@mhsn.net>2026-01-18 11:30:32 +0000
commit940d5ca4550b2d1231fad80f55a7186ceca66e45 (patch)
treef9181dadd1d49d65bccea0f4678659cc26b0d328 /2025/09/rust/src/main.rs
parentfb78659f05d5d72c819d316bebc960fc48472bbd (diff)
downloadaoc-940d5ca4550b2d1231fad80f55a7186ceca66e45.tar.gz
aoc-940d5ca4550b2d1231fad80f55a7186ceca66e45.zip
25-09 rust
Diffstat (limited to '2025/09/rust/src/main.rs')
-rw-r--r--2025/09/rust/src/main.rs27
1 files changed, 27 insertions, 0 deletions
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)
+}