1
0
Fork 0

day(11): use iterators instead of the ‹for› loops

Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
Matej Focko 2023-12-11 10:53:30 +01:00
parent af6cba1445
commit bcdea3496b
Signed by: mfocko
GPG key ID: 7C47D46246790496

View file

@ -34,17 +34,8 @@ impl Day11 {
let min_x = min(x0, x1); let min_x = min(x0, x1);
let max_x = max(x0, x1); let max_x = max(x0, x1);
for x in &self.empty_xs { xd += to_add * self.empty_xs.iter().filter(|&&x| min_x < x && x < max_x).count();
if min_x < *x && *x < max_x { yd += to_add * self.empty_ys.iter().filter(|&&y| y0 < y && y < y1).count();
xd += to_add;
}
}
for y in &self.empty_ys {
if y0 < *y && *y < y1 {
yd += to_add;
}
}
xd + yd xd + yd
}) })