Fix Clippy issues.
This commit is contained in:
parent
0951a5930a
commit
b44b540020
|
@ -32,13 +32,7 @@ fn part_1(input: &str) -> Result<String> {
|
|||
}
|
||||
}
|
||||
|
||||
Ok(
|
||||
memory
|
||||
.iter()
|
||||
.map(|(_, value)| value)
|
||||
.sum::<i64>()
|
||||
.to_string(),
|
||||
)
|
||||
Ok(memory.values().sum::<i64>().to_string())
|
||||
}
|
||||
|
||||
fn part_2(input: &str) -> Result<String> {
|
||||
|
@ -98,13 +92,7 @@ fn part_2(input: &str) -> Result<String> {
|
|||
}
|
||||
}
|
||||
|
||||
Ok(
|
||||
memory
|
||||
.iter()
|
||||
.map(|(_, value)| *value)
|
||||
.sum::<i64>()
|
||||
.to_string(),
|
||||
)
|
||||
Ok(memory.values().sum::<i64>().to_string())
|
||||
}
|
||||
|
||||
fn combine(input: String) -> Vec<String> {
|
||||
|
|
|
@ -15,30 +15,18 @@ impl Vector {
|
|||
let x_coordinates = {
|
||||
let x_amount = (self.a.0 - self.b.0).abs();
|
||||
if self.a.0 < self.b.0 {
|
||||
(0..=x_amount)
|
||||
.into_iter()
|
||||
.map(|x| self.a.0 + x)
|
||||
.collect::<Vec<_>>()
|
||||
(0..=x_amount).map(|x| self.a.0 + x).collect::<Vec<_>>()
|
||||
} else {
|
||||
(0..=x_amount)
|
||||
.into_iter()
|
||||
.map(|x| self.a.0 - x)
|
||||
.collect::<Vec<_>>()
|
||||
(0..=x_amount).map(|x| self.a.0 - x).collect::<Vec<_>>()
|
||||
}
|
||||
};
|
||||
|
||||
let y_coordinates = {
|
||||
let y_amount = (self.a.1 - self.b.1).abs();
|
||||
if self.a.1 < self.b.1 {
|
||||
(0..=y_amount)
|
||||
.into_iter()
|
||||
.map(|x| self.a.1 + x)
|
||||
.collect::<Vec<_>>()
|
||||
(0..=y_amount).map(|x| self.a.1 + x).collect::<Vec<_>>()
|
||||
} else {
|
||||
(0..=y_amount)
|
||||
.into_iter()
|
||||
.map(|x| self.a.1 - x)
|
||||
.collect::<Vec<_>>()
|
||||
(0..=y_amount).map(|x| self.a.1 - x).collect::<Vec<_>>()
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -54,7 +42,7 @@ impl Vector {
|
|||
(self.b.0, self.a.0)
|
||||
};
|
||||
|
||||
(x1..=x2).into_iter().map(|x| (x, y)).collect()
|
||||
(x1..=x2).map(|x| (x, y)).collect()
|
||||
}
|
||||
|
||||
fn vertical_coordinates(&self) -> Vec<(isize, isize)> {
|
||||
|
@ -66,7 +54,7 @@ impl Vector {
|
|||
(self.b.1, self.a.1)
|
||||
};
|
||||
|
||||
(y1..=y2).into_iter().map(|y| (x, y)).collect()
|
||||
(y1..=y2).map(|y| (x, y)).collect()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ fn parse_fishes(input: &str) -> Result<FishMap> {
|
|||
}
|
||||
|
||||
fn count_fishes(fishes: FishMap) -> isize {
|
||||
fishes.into_iter().map(|(_, amount)| amount).sum()
|
||||
fishes.values().sum()
|
||||
}
|
||||
|
||||
fn simulate_fishes(fishes: FishMap) -> FishMap {
|
||||
|
|
Loading…
Reference in New Issue