day(11): use iterators instead of the ‹for› loops
Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
parent
af6cba1445
commit
bcdea3496b
1 changed files with 2 additions and 11 deletions
|
@ -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
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue