Skip to content

Instantly share code, notes, and snippets.

Created September 2, 2014 19:39
Show Gist options
  • Save anonymous/4d90bd22e5df160e067e to your computer and use it in GitHub Desktop.
Save anonymous/4d90bd22e5df160e067e to your computer and use it in GitHub Desktop.
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