Created
September 2, 2014 19:39
-
-
Save anonymous/4d90bd22e5df160e067e 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 score(dice) | |
sum = 0 | |
(1..6).each do |i| | |
idice = dice.select { |d| d == i } | |
if idice.size >= 3 | |
sum += (i==1 ? 1000 : i*100) | |
end | |
sum += (idice.size % 3) * 100 if i == 1 | |
sum += (idice.size % 3) * 50 if i == 5 | |
end | |
sum | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment