Skip to content

Commit 67ea808

Browse files
committed
Completed about scoring
1 parent fb21cf1 commit 67ea808

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

python2/koans/about_scoring_project.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,23 @@
3434
# Your goal is to write the score method.
3535

3636
def score(dice):
37-
# You need to write this method
38-
pass
37+
counts = { number: 0 for number in range(1,7) }
38+
for number in dice:
39+
counts[number] = counts[number] + 1
40+
41+
score = 0
42+
if counts[1] >= 3:
43+
score += 1000
44+
counts[1] -= 3
45+
for number in range(2,7):
46+
if counts[number] >= 3:
47+
score += number * 100
48+
counts[number] -= 3
49+
if counts[1] > 0:
50+
score += 100 * counts[1]
51+
if counts[5] > 0:
52+
score += 50 * counts[5]
53+
return score
3954

4055

4156
class AboutScoringProject(Koan):

0 commit comments

Comments
 (0)