minor cleanup

This commit is contained in:
swaits committed 2021-12-06 19:48:35 -07:00
1 parent c880839306
commit 41c4fc5a51
1 file changed
+4 -3
+4 -3
View File
@@ -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::<usize>()
}
fn count_population(pop: &Vec<isize>, 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::<isize>(include_str!("../data/day06.txt"), ',').unwrap();
assert_eq!(count_population(&data, 80), 358214);
assert_eq!(count_population(&data, 256), 1622533344325);
}
}