DEV Community

Discussion on: Daily Challenge #41 - Greed is Good

Collapse
 
geraldhost profile image
Gerald Host

A super gross unreadable solution but fun none the less 😂

def score(inp):
    def single_score(n, c):
        return (n * (100 if n != 1 else 1000) if c >= 3 and n in t else 0) + ((n * (10 if n != 1 else 100)) * (c - (3 if c >= 3 else 0)) if n in s else 0)
    return sum([single_score(n, c) for n, c in {i: inp.count(i) for i in inp}.items()])

score([2, 4, 4, 5, 4]) # 450