Skip to content

Instantly share code, notes, and snippets.

@ugisozols
Created June 22, 2010 12:54
Show Gist options
  • Save ugisozols/448432 to your computer and use it in GitHub Desktop.
Save ugisozols/448432 to your computer and use it in GitHub Desktop.
def score(dice)
points = 0
roll = { 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0 }
dice.each { |i| roll[i] += 1}
roll.each do |key, value|
case key
when 1
if value >= 3
points += 1000
value = value - 3
end
points += 100 * value
when 5
if value >= 3
points += 100 * 5
value = value - 3
end
points += 50 * value
else
points += 100 * key if value >= 3
end
end
return points
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment