Skip to content

Instantly share code, notes, and snippets.

@ssugiyama
Created December 12, 2016 10:29
Show Gist options
  • Save ssugiyama/ad76e60f30b9f02fd3df8f3bae68d7f3 to your computer and use it in GitHub Desktop.
Save ssugiyama/ad76e60f30b9f02fd3df8f3bae68d7f3 to your computer and use it in GitHub Desktop.
あめの数から最大限進化可能な回数を求める
def poppo(candies, n=12)
evolutions = (candies/n).to_i
rest = evolutions *2 + candies%n
evolutions += poppo(rest) if rest >= n
evolutions
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment