Game

mail@pastecode.io avatar
unknown
python
2 years ago
661 B
33
Indexable
Never
a = [0]
for i in range(1, 1000):
    a.append(a[len(a) - 1] + i)

def mex(l):
    ans = 0
    while ans in l:
        ans += 1
    return ans

def move(x):
    ret = []
    for i in range(x):
        for j in range(i):
            if a[i] - a[j] == x:
                ret.append(list(range(j + 1, i + 1)))
    return ret

def grundy(s):
    if len(s) == 1:
        a = []
        for i in move(s[0]):
            a.append(grundy(i))
        return mex(a)
    ans = 0
    for i in s:
        ans ^= grundy([i])
    return ans
while True:
#    x = int(input())
#    for i in move(x):
#        print(i)
    s = list(map(int, input().split()))
    print(grundy(s))