chore: clippy

This commit is contained in:
Matej Janezic 2022-12-09 19:47:58 +01:00
parent 0000032005
commit 0000033015
Signed by: janezicmatej
GPG Key ID: 4298E230ED37B2C0
2 changed files with 5 additions and 5 deletions

View File

@ -137,11 +137,11 @@ mod tests {
#[test] #[test]
fn test_part_one() { fn test_part_one() {
let input = aoc::read_file("test_inputs", 15); let input = aoc::read_file("test_inputs", 15);
assert_eq!(part_one(&input.trim()), Some(62842880)); assert_eq!(part_one(input.trim()), Some(62842880));
} }
#[test] #[test]
fn test_part_two() { fn test_part_two() {
let input = aoc::read_file("test_inputs", 15); let input = aoc::read_file("test_inputs", 15);
assert_eq!(part_two(&input.trim()), Some(57600000)); assert_eq!(part_two(input.trim()), Some(57600000));
} }
} }

View File

@ -9,7 +9,7 @@ pub fn part_one(input: &str) -> Option<u32> {
containers containers
.iter() .iter()
.combinations(x) .combinations(x)
.map(|y| y.iter().map(|w| *w).sum::<u32>()) .map(|y| y.iter().copied().sum::<u32>())
.filter(|&z| z == 150) .filter(|&z| z == 150)
.count() .count()
}) })
@ -23,12 +23,12 @@ pub fn part_two(input: &str) -> Option<u32> {
containers containers
.iter() .iter()
.combinations(x) .combinations(x)
.map(|y| (y.len(), y.iter().map(|w| *w).sum::<u32>())) .map(|y| (y.len(), y.iter().copied().sum::<u32>()))
.filter(|(_, z)| z == &150) .filter(|(_, z)| z == &150)
.map(|(t, _)| t) .map(|(t, _)| t)
.collect_vec() .collect_vec()
}) })
.filter(|x| x.len() > 0) .filter(|x| !x.is_empty())
.map(|x| { .map(|x| {
let m = x.iter().min().unwrap(); let m = x.iter().min().unwrap();
(*m, x.iter().filter(|&y| y == m).count()) (*m, x.iter().filter(|&y| y == m).count())