Skip to content

Commit 610e463

Browse files
committed
Finished AboutScoringProject
1 parent 141a135 commit 610e463

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

python2/koans/about_scoring_project.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,28 @@
3333
#
3434
# Your goal is to write the score method.
3535

36+
3637
def score(dice):
3738
# You need to write this method
38-
pass
39+
numbers = {}.fromkeys(range(0, 10), 0)
40+
for d in dice:
41+
numbers[d] += 1
42+
43+
# * A set of three ones is 1000 points
44+
sum = (numbers[1] // 3) * 1000
45+
46+
# * A one (that is not part of a set of three) is worth 100 points.
47+
sum += (numbers[1] % 3) * 100
48+
49+
# * A five (that is not part of a set of three) is worth 50 points.
50+
sum += (numbers[5] % 3) * 50
51+
52+
# * A set of three numbers (other than ones) is worth 100 times the number
53+
for r in range(2, 10):
54+
sum += (numbers[r] // 3) * 100 * r
55+
56+
return sum
57+
3958

4059

4160
class AboutScoringProject(Koan):

0 commit comments

Comments
 (0)