Skip to content

Instantly share code, notes, and snippets.

@benlangfeld
Created November 6, 2011 01:46
Show Gist options
  • Save benlangfeld/1342342 to your computer and use it in GitHub Desktop.
Save benlangfeld/1342342 to your computer and use it in GitHub Desktop.
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