Skip to content

Instantly share code, notes, and snippets.

@gphil
Created August 2, 2012 22:28
Show Gist options
  • Save gphil/3241397 to your computer and use it in GitHub Desktop.
Save gphil/3241397 to your computer and use it in GitHub Desktop.
scoring_project
def score(dice)
d = {}
dice.each do |i|
d[i] ||= 0
d[i] += 1
end
n = 0
d.each do |k, v|
if v >= 3
if k == 1
n += 1000
else n += 100 * k
end
v -= 3
end
v.times do
n += case k
when 1
100
when 5
50
else 0
end
end
end
n
end
##
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment