>>107258935
>wrong
How exactly? Your screenshot doesn't show your full code, but:
>line 6, 0..3
>line 9, iterating x over the entire width for each 0..3
>line 10, iterating y over the entire height for each x
It sure looks like you do at least one check for every cell, and call 'fire' (whatever that function is) on every non-destroyed cell. There's no sign of any root finding.
My code only checks roots each loop, no whole-grid iteration:
for _ in 0..3 {
let (size, region) = roots
.par_iter()
.map(|&(ry, rx)| {
let region = flood_region(&grid, &dead, ry, rx);
(region.len(), region)
})
.max_by_key(|p| p.0)
.unwrap();
for (y, x) in region {
dead[y][x] = true;
}
total += size;