Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
982 B
1
Indexable
Never
from functools import *
def moves(h, last = ''):
    
    if last == '+1':
        vars = (h + 2, '+2'), (h * 3, '*3')
    elif last == '+2':
        vars = (h + 1, '+1'), (h * 3, '*3')
    elif last == '*3':
        vars = (h + 1, '+1'), (h + 2, '+2')
    else:
        vars = (h + 1, '+1'), (h + 2, '+2'), (h * 3, '*3')
    return vars
@cache
def f(h, last = ''):
    if h >= 140:
        return 'end'
    if any(f(*x) == 'end' for x in moves(h, last)):
        return 'win1'
    if all(f(*x) == 'win1' for x in moves(h, last)):
        return 'lose1'
    if any(f(*x) == 'lose1' for x in moves(h, last)):
        return 'win2'
    if all(f(*x) == 'win1' or f(*x) == 'win2' for x in moves(h)):
        return 'lose2'
lose1 = []
win2 = []
lose2 =[]
for i in range(1, 140):
    if f(i) == 'lose1':
        lose1.append(i)
    if f(i) == 'win2':
        win2.append(i)
    if f(i) == 'lose2':
        lose2.append(i)
print('lose1', *lose1)
print('win2', *win2)
print('lose2', *lose2)