Implement AoC 2025 #1

Open
leon wants to merge 22 commits from 2025 into main
Showing only changes of commit 4fe10ee925 - Show all commits

View File

@@ -11,7 +11,7 @@ enum Cell {
}
fn main() {
let grid: Vec<_> = CONTENT.lines().map(|l| l.trim()).filter(|l| !l.is_empty()).map(|l| {
let mut grid: Vec<_> = CONTENT.lines().map(|l| l.trim()).filter(|l| !l.is_empty()).map(|l| {
l.chars().map(|c| match c {
'.' => Cell::Empty,
'@' => Cell::PRoll,
@@ -20,6 +20,9 @@ fn main() {
}).collect();
let mut result = 0;
loop {
let mut to_remove = Vec::new();
for (y, row) in grid.iter().enumerate() {
for (x, cell) in row.iter().enumerate() {
if cell != &Cell::PRoll {
@@ -34,9 +37,19 @@ fn main() {
if neighbours < 4 {
result += 1;
to_remove.push((x, y));
}
}
}
if to_remove.is_empty() {
break;
}
for (x, y) in to_remove {
grid[y][x] = Cell::Empty;
}
}
println!("Result: {}", result);
}