Module advent_of_code_2021::day_6 [−][src]
Expand description
This is my solution for Advent of Code - Day 6 - Lanternfish
There is always at least one puzzle each year where a naive implementation is fairly simple, but part two expands the problem size so that the naive solution will take too long to run. This is one of those.
Experience from previous years allowed me to spot that and implement a more performant solution
to part one, simulate. This requires the population count for each day, so there is also
parse_input that reduces the puzzle input to this format. Part two calls simulate again,
but with a higher number of days.
Functions
Reduces a comma-separated list of numbers representing the number of days until that fish will next reproduce, into a summary array that contains the count for each day.
The entry point for running the solutions with the ‘real’ puzzle input.
Recursive function that iterates the population days times, returning the resulting
population summary.
