-
-
Save havenwood/377956e68d54206d3cd00f127ef0c6e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REDUCE_POPULATION = -> population do | |
return population - 2 if population > 2 | |
population | |
end.freeze | |
def num_rabbits(answers) | |
answers.tally.transform_values(&REDUCE_POPULATION) | |
end | |
num_rabbits [1,0,1,0,0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment