~swaits/aoc2021

41c4fc5a512218867206b25002a91b1a99e62f68 — Stephen Waits 1 year, 9 months ago c880839
minor cleanup
1 files changed, 4 insertions(+), 3 deletions(-)

M src/day06.rs
M src/day06.rs => src/day06.rs +4 -3
@@ 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);
    }
}