Untitled
Anonymous
plain_text
03/15/2022 4:58 AM
668 B
14
Indexable
from functools import lru_cache
def moves(h):
return h + 1, h + 2, h + 3
@lru_cache(None)
def f(n):
if h>=50:
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' for x in moves(h)):
return 'В2'
for i in range(1, 50):
h = i
print(i, f(i))Editor is loading...