Created
November 6, 2011 01:46
-
-
Save benlangfeld/1342342 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
SINGLE_ROLL_MULTIPLIERS = [0, 100, 0, 0, 0, 50, 0] | |
def score(dice) | |
score = 0 | |
(1..6).each do |number| | |
roll_count = dice.count { |dice| dice == number } | |
if roll_count >= 3 | |
score += number == 1 ? 1000 : 100 * number | |
roll_count -= 3 | |
end | |
score += roll_count * SINGLE_ROLL_MULTIPLIERS[number] | |
end | |
score | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment