diff options
| author | mhsn <mail@mhsn.net> | 2025-12-04 09:59:21 +0000 |
|---|---|---|
| committer | mhsn <mail@mhsn.net> | 2025-12-05 09:54:04 +0000 |
| commit | 34aca76798e8f9f4ac5b2d93619953edebb4c89d (patch) | |
| tree | dc5a94fbb9c925b1f97fe21805ccda36925cef61 | |
| parent | af450561d3273c387baa8ff15cbefc2ff2482486 (diff) | |
| download | aoc-34aca76798e8f9f4ac5b2d93619953edebb4c89d.tar.gz aoc-34aca76798e8f9f4ac5b2d93619953edebb4c89d.zip | |
25-04 rust
| -rw-r--r-- | 2025/04/rust/Cargo.lock | 7 | ||||
| -rw-r--r-- | 2025/04/rust/Cargo.toml | 6 | ||||
| -rw-r--r-- | 2025/04/rust/src/main.rs | 32 |
3 files changed, 45 insertions, 0 deletions
diff --git a/2025/04/rust/Cargo.lock b/2025/04/rust/Cargo.lock new file mode 100644 index 0000000..222070d --- /dev/null +++ b/2025/04/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-04" +version = "0.1.0" diff --git a/2025/04/rust/Cargo.toml b/2025/04/rust/Cargo.toml new file mode 100644 index 0000000..b29e6d6 --- /dev/null +++ b/2025/04/rust/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "aoc_2025-04" +version = "0.1.0" +edition = "2024" + +[dependencies] diff --git a/2025/04/rust/src/main.rs b/2025/04/rust/src/main.rs new file mode 100644 index 0000000..5d703c5 --- /dev/null +++ b/2025/04/rust/src/main.rs @@ -0,0 +1,32 @@ +use std::io; + +fn main() { + let mut grid: Vec<Vec<Option<usize>>> = io::stdin() + .lines() + .flatten() + .map(|line| line.chars().map(|ch| (ch == '@').then_some(0)).collect()) + .collect(); + + for (y, row) in grid.iter().enumerate() { + for (x, p) in row.iter().enumerate() { + let Some(_) = p else { + continue; + }; + + for nx in x.saturating_sub(1)..=(x + 1).min(row.len() - 1) { + for ny in y.saturating_sub(1)..=(y + 1).min(grid.len() - 1) { + // lol quadruple for loop (this makes me sad) + if (x, y) == (nx, ny) { + continue; + } + let mut h = grid.get(ny).and_then(|r| r.get(nx)).unwrap(); + } + } + } + } + + let silver: u64 = 0; + let gold: u64 = 0; + println!("silver: {silver}"); + println!("gold: {gold}"); +} |
