Skip to content

Instantly share code, notes, and snippets.

@cpjk
Last active August 29, 2015 14:01
Show Gist options
  • Save cpjk/b1de1c3b8b3a13b7000a to your computer and use it in GitHub Desktop.
Save cpjk/b1de1c3b8b3a13b7000a to your computer and use it in GitHub Desktop.
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