We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 141a135 commit 610e463Copy full SHA for 610e463
1 file changed
python2/koans/about_scoring_project.py
@@ -33,9 +33,28 @@
33
#
34
# Your goal is to write the score method.
35
36
+
37
def score(dice):
38
# You need to write this method
- 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
58
59
60
class AboutScoringProject(Koan):
0 commit comments