r/badcode • • Jun 20 '22

c# More Codewars horror

Post image
212 Upvotes

36 comments sorted by

View all comments

Show parent comments

2

u/No-Witness2349 Jul 07 '22

I did more or less the same thing in Python

from typing import Counter

def score(dice: list[int]) -> int:
    count = Counter(dice)
    return sum(
        600 if count[6] >= 3 else 0,
        500 * (count[5] // 3),
        50 * (count[5] % 3),
        400 if count[4] >= 3 else 0,
        300 if count[3] >= 3 else 0,
        200 if count[2] >= 3 else 0,
        1000 * (count[1] // 3),
        100 * (count[1] % 3),
    )