From 41c4fc5a512218867206b25002a91b1a99e62f68 Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Mon, 6 Dec 2021 19:48:35 -0700 Subject: [PATCH] minor cleanup --- src/day06.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/day06.rs b/src/day06.rs index 6d3b968..90d72e3 100644 --- a/src/day06.rs +++ b/src/day06.rs @@ -8,11 +8,11 @@ fn count_babies(birthday: isize, end_day: isize) -> usize { 1 + (birthday..=end_day) .skip(2 + 7) .step_by(7) - .map(|day| count_babies(day, end_day) as usize) + .map(|day| count_babies(day, end_day)) .sum::() } -fn count_population(pop: &Vec, end_day: isize) -> usize { +fn count_population(pop: &[isize], end_day: isize) -> usize { pop.iter().map(|d| count_babies(d - 8, end_day)).sum() } @@ -26,7 +26,7 @@ mod tests { use super::*; #[test] - fn emit_babies() { + fn test_count_babies() { assert_eq!(count_babies(3 - 8, 18), 5); } @@ -42,5 +42,6 @@ mod tests { fn test_my_data() { let data = parse_by_char::(include_str!("../data/day06.txt"), ',').unwrap(); assert_eq!(count_population(&data, 80), 358214); + assert_eq!(count_population(&data, 256), 1622533344325); } } -- 2.45.2