Here is my simple solution with Python:
def score(dice): dice_count = [0, 0, 0, 0, 0, 0] sum = 0 for point in dice: dice_count[point-1] += 1 while dice_count[0] >= 3: sum += 1000 dice_count[0] -= 3 if dice_count[0] <= 2 and dice_count != 0: sum += 100 * dice_count[0] if dice_count[1] >= 3: sum += 200 else: sum += 0 if dice_count[2] >= 3: sum += 300 else: sum += 0 if dice_count[3] >= 3: sum += 400 else: sum += 0 while dice_count[4] >= 3: sum += 500 dice_count[4] -= 3 if dice_count[4] <= 2 and dice_count[4] != 0: sum += 50 * dice_count[4] if dice_count[5] >= 3: sum += 600 else: sum += 0 return sum
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Here is my simple solution with Python: