Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from functools import lru_cache
- def moves(s):
- a, b = s[0], s[1]
- return (a - 1, b), (a // 2, b), (a, b - 1), (a, b // 2)
- @lru_cache(None)
- def f(s, depth):
- if depth >= 100:
- return None
- if sum(s) <= 20:
- return 'win'
- if any(f(x, depth + 1) == 'win' for x in moves(s)):
- return 'p1'
- if all(f(x, depth + 1) == 'p1' for x in moves(s)):
- return 'v1'
- if any(f(x, depth + 1) == 'v1' for x in moves(s)):
- return 'p2'
- if all(f(x, depth + 1) == 'p2' or f(x, depth + 1) == 'p1' for x in moves(s)):
- return 'v2'
- for i in range(10, 100):
- print(i, f((10, i), 0))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement