my attempt using Python:
from collections import Counter def score(values): """ Greed is good scoring >>> score((5,1,3,4,1)) 250 >>> score((1,1,1,3,1)) 1100 >>> score((2,4,4,5,4)) 450 """ count = Counter(values) score = 0 for value, amount in count.items(): if value > 6: raise ValueError("Invalid dice value") if value == 1: value = 10 trip, left = divmod(amount, 3) score += trip * value * 100 if value in (10, 5): score += left * value * 10 return score if __name__ == "__main__": import doctest doctest.testmod(verbose=True)
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.
my attempt using Python: