Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #19 20 21 https://inf-ege.sdamgia.ru/test?id=17275341
- from functools import lru_cache
- def moves(h):
- x, y = h
- return (x + 1, y), (x, y + 1), (x * 2, y), (x, y * 2)
- @lru_cache(None)
- def game(h):
- if sum(h) >= 86:
- return 'WIN'
- elif any(game(m) == 'WIN' for m in moves(h)):
- return 'P1'
- elif all(game(m) in ['P1'] for m in moves(h)):
- return 'V1'
- elif any(game(m) == 'V1' for m in moves(h)):
- return 'P2'
- elif all(game(m) in ['P1', 'P2'] for m in moves(h)):
- return 'V2'
- def p19(h):
- return any(game(m) == 'P1' for m in moves(h))
- print([s for s in range(1, 72) if p19((14, s))]) #ваня выиграл первым ходом
- print([s for s in range(1, 72) if game((14, s)) == 'P2']) #петя вторым ходом
- print([s for s in range(1, 72) if game((14, s)) == 'V2'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement