Created
August 2, 2012 22:28
-
-
Save gphil/3241397 to your computer and use it in GitHub Desktop.
scoring_project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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