Решение 1
def moves(h):
a, b = h
return (a + 4, b), (a * 2, b), (a, b + 4), (a, b * 2)
def game_over(h):
return sum(h) >= 165
def win1(h):
return not game_over(h) and any(game_over(m) for m in moves(h))
def lose1(h):
return not win1(h) and all(win1(m) for m in moves(h))
def win2(h):
return not win1(h) and any(lose1(m) for m in moves(h))
def lose2(h):
return (
not win1(h)
and not win2(h)
and all(win1(m) or win2(m) for m in moves(h))
and any(win2(m) for m in moves(h))
)
def win3(h):
return not win1(h) and not win2(h) and any(lose2(m) for m in moves(h))
def lose3(h):
return (
not win1(h)
and not win2(h)
and not win3(h)
and all(win1(m) or win2(m) or win3(m) for m in moves(h))
and any(win3(m) for m in moves(h))
)
for s in range(1, 151):
if (lose2((14, s)) or lose3((14, s))) and not win2((14, s)):
print(s)
break