Last active
August 29, 2015 14:01
-
-
Save cpjk/b1de1c3b8b3a13b7000a 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) | |
score, values = 0, Hash.new(0) | |
dice.each {|roll_value| values[roll_value] += 1} | |
(2..6).each { |i| score += i*100 if values[i]>=3} | |
return score = score + (values[5] > 3 ? ((values[5]-3)*50) : 0) + (values[1] > 3 ? ((values[1]-3)*100) : 0) + (values[5] < 3 ? (values[5]*50) : 0) + (values[1] >= 3 ? 1000 : values[1]*100) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment