From 0e3e8397803cc4afb8584a22cea01ad62fa9fe3e Mon Sep 17 00:00:00 2001 From: Steven Date: Fri, 24 Jan 2020 14:08:42 -0300 Subject: [PATCH 1/2] Completed the about_scoring_project koan --- python2/koans/about_scoring_project.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/python2/koans/about_scoring_project.py b/python2/koans/about_scoring_project.py index da51563b4..f43bbf89e 100644 --- a/python2/koans/about_scoring_project.py +++ b/python2/koans/about_scoring_project.py @@ -34,8 +34,21 @@ # Your goal is to write the score method. def score(dice): + final_score = 0 + repeated_nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + for number in dice: + repeated_nums[number]=repeated_nums[number] + 1 + for i in range(0,10): + aux1 = int (repeated_nums[i] / 3) + aux2 = repeated_nums[i] % 3 + if i == 1: + final_score = final_score + (aux1 * 1000) + (aux2 * 100) + elif i == 5: + final_score = final_score + (aux1 * 100 * 5) + (aux2 * 50) + else: + final_score = final_score + (aux1 * 100 * i) # You need to write this method - pass + return final_score class AboutScoringProject(Koan): From 45fd6f69e5ac3958e6f1de915b9e373296951d0f Mon Sep 17 00:00:00 2001 From: Steven Desvars Date: Sun, 15 Mar 2020 21:04:17 -0300 Subject: [PATCH 2/2] Addressed all the comments --- python2/koans/about_scoring_project.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/python2/koans/about_scoring_project.py b/python2/koans/about_scoring_project.py index f43bbf89e..3bf5c7583 100644 --- a/python2/koans/about_scoring_project.py +++ b/python2/koans/about_scoring_project.py @@ -35,12 +35,14 @@ def score(dice): final_score = 0 - repeated_nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + repeated_nums = [0, 0, 0, 0, 0, 0] for number in dice: - repeated_nums[number]=repeated_nums[number] + 1 - for i in range(0,10): - aux1 = int (repeated_nums[i] / 3) + repeated_nums[number-1]=repeated_nums[number-1] + 1 + for i in xrange(len(repeated_nums)): + aux1 = repeated_nums[i] // 3 aux2 = repeated_nums[i] % 3 + # This change the values of i from 0-5 to 1-6. + i += 1 if i == 1: final_score = final_score + (aux1 * 1000) + (aux2 * 100) elif i == 5: