Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from functools import lru_cache
- def moves(a):
- return a + 1, a + 4, a * 5
- @lru_cache(None)
- def game(x):
- if x >= 68:
- return 'WIN'
- if any(game(e) == 'WIN' for e in moves(x)):
- return 'P1'
- if all(game(e) == 'P1' for e in moves(x)):
- return 'V1'
- if any(game(e) == 'V1' for e in moves(x)):
- return 'P2'
- if all(game(e) in ['P1', 'P2'] for e in moves(x)):
- return 'V2'
- def p19(x):
- return any(game(e) == 'P1' for e in moves(x))
- print([s for s in range(1, 68) if p19(s)])
- print([s for s in range(1, 68) if game(s) == 'P2'])
- print([s for s in range(1, 68) if game(s) == 'V2'])
Advertisement
Add Comment
Please, Sign In to add comment