Skip to content

Instantly share code, notes, and snippets.

@havenwood
Last active July 23, 2019 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save havenwood/377956e68d54206d3cd00f127ef0c6e6 to your computer and use it in GitHub Desktop.
Save havenwood/377956e68d54206d3cd00f127ef0c6e6 to your computer and use it in GitHub Desktop.
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