Skip to content

Instantly share code, notes, and snippets.

@jimrollenhagen
Created January 30, 2011 23:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimrollenhagen/803412 to your computer and use it in GitHub Desktop.
Save jimrollenhagen/803412 to your computer and use it in GitHub Desktop.
def score(dice)
score = 0
points = { 1 => 100, 2 => 0, 3 => 0, 4 => 0, 5 => 50, 6 => 0 }
points_trip = { 1 => 1000, 2 => 200, 3 => 300, 4 => 400, 5 => 500, 6 => 600 }
(1..6).map { |i|
count = dice.count(i)
score += (count / 3) * points_trip[i] + (count % 3) * points[i]
}
score
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment