Skip to content

Instantly share code, notes, and snippets.

@spinagon
Created November 28, 2011 16:02
Show Gist options
  • Save spinagon/1400894 to your computer and use it in GitHub Desktop.
Save spinagon/1400894 to your computer and use it in GitHub Desktop.
def score(dice)
sum = 0
count = Hash.new(0)
dice.each {|die| count[die == 1 ? :"10" : :"#{die}"] += 1}
count.each {|d, c| sum += d.to_s.to_i * 100 * (c / 3); count[d] = c % 3}
sum += count[:"10"] * 100 + count[:"5"] * 50
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment