Created
December 12, 2016 10:29
-
-
Save ssugiyama/ad76e60f30b9f02fd3df8f3bae68d7f3 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
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