loading...

re: Daily Challenge #41 - Greed is Good VIEW POST

FULL DISCUSSION
 

Python

import random
def pounts(p):
    if p == 1:
        return 1000
    else:
        return p*100
def greed():
    d=sorted(random.choices(range(1,7),k=5))
    print(d)
    dice = 1
    p = 0
    while len(d) > 0:
        if d.count(dice) >= 3:
            p += pounts(dice)
            del d[:4]
        elif (d[0] == 1 or d[0] == 5) and (dice == 5 or dice == 1):
            if d.count(1) == 2 or d.count(5) == 2:
                p += int(100 if d[0] == 1 else 50) * 2
                del d[:2]
            else:
                p += int(100 if d[0] == 1 else 50)
                d.pop(0)
            dice += 1
        else:
            if d[0] == dice and d.count(dice) == 1:
                d.pop(0)
            elif d[0] == dice and d.count(dice) == 2:
                del d[:2]
            dice += 1
    return p
code of conduct - report abuse