2019: day08: fix clippy lints
This commit is contained in:
parent
56adb541a0
commit
83fa28b21d
|
@ -26,20 +26,20 @@ fn part1(image: &Image) -> Result<usize> {
|
||||||
let most_zero_layer = image
|
let most_zero_layer = image
|
||||||
.layers
|
.layers
|
||||||
.iter()
|
.iter()
|
||||||
.min_by_key(|l| l.pixels.iter().flat_map(|l| l).filter(|d| **d == 0).count())
|
.min_by_key(|l| l.pixels.iter().flatten().filter(|d| **d == 0).count())
|
||||||
.ok_or_else(|| err!("image had 0 layers..."))?;
|
.ok_or_else(|| err!("image had 0 layers..."))?;
|
||||||
|
|
||||||
let one_count = most_zero_layer
|
let one_count = most_zero_layer
|
||||||
.pixels
|
.pixels
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|l| l)
|
.flatten()
|
||||||
.filter(|d| **d == 1)
|
.filter(|d| **d == 1)
|
||||||
.count();
|
.count();
|
||||||
|
|
||||||
let two_count = most_zero_layer
|
let two_count = most_zero_layer
|
||||||
.pixels
|
.pixels
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|l| l)
|
.flatten()
|
||||||
.filter(|d| **d == 2)
|
.filter(|d| **d == 2)
|
||||||
.count();
|
.count();
|
||||||
|
|
||||||
|
@ -99,10 +99,10 @@ impl FromStr for Image {
|
||||||
|
|
||||||
// overlap layers
|
// overlap layers
|
||||||
for layer in layers.iter() {
|
for layer in layers.iter() {
|
||||||
for i in 0..layer.pixels.len() {
|
for (src_row, dst_row) in layer.pixels.iter().zip(result.iter_mut()) {
|
||||||
for j in 0..layer.pixels[i].len() {
|
for (src_pixel, dst_pixel) in src_row.iter().zip(dst_row.iter_mut()) {
|
||||||
if let 2 = result[i][j] {
|
if let 2 = *dst_pixel {
|
||||||
result[i][j] = layer.pixels[i][j];
|
*dst_pixel = *src_pixel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue