Untitled
unknown
plain_text
4 years ago
540 B
4
Indexable
from functools import lru_cache
def moves(h):
a, b = h
return (a+1, b), (a, b+1), (a*2, b), (a, b*2), (a*3, b), (a, b*3)
@lru_cache(None)
def f(h):
if (sum(h) >= 84):
return 'END'
elif any(f(x)=='END' for x in moves(h)):
return 'П1'
elif all(f(x)=='П1' for x in moves(h)):
return 'В1'
elif any(f(x)=='В1' for x in moves(h)):
return 'П2'
elif all(f(x)=='П2' or f(x) == 'П1' for x in moves(h)):
return 'В2'
for i in range(1, 68):
h = 16, i
print(i, f(i))Editor is loading...