day1: part2

This commit is contained in:
ktims committed 2026-11-30 22:23:42 -07:00
1 parent db575f5217
commit 9d1258c972
1 file changed
+6 -2
+6 -2
View File
@@ -13,7 +13,11 @@ pub fn part1(input: &str) -> u64 {
#[aoc(day1, part2)]
pub fn part2(input: &str) -> u64 {
0
let ids = input.lines().map(|l| l.parse::<u64>().unwrap()).counts();
ids.iter()
.sorted_by_key(|(_k, v)| *v)
.take(3)
.fold(1, |acc, (k, _v)| acc * k)
}
#[cfg(test)]
@@ -49,6 +53,6 @@ mod tests {
#[test]
fn problem2_example() {
assert_eq!(part2(EXAMPLE), 0);
assert_eq!(part2(EXAMPLE), 193050);
}
}