Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from functools import lru_cache
- def moves(h):
- a = h
- answ = []
- if (a + 1) % 3 != 0:
- answ.append(a + 1)
- if (a + 2) % 3 != 0:
- answ.append(a + 2)
- if (a * 2) % 3 != 0:
- answ.append(a * 2)
- return answ
- @lru_cache(None)
- def game (h):
- if h >= 151:
- return 'win'
- elif any(game(m) == 'win' for m in moves(h)):
- return'p1'
- elif all (game(m) == '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, 150) if (s % 3 != 0) and game(s) == 'v1'])
- print([s for s in range(1, 150) if (s % 3 != 0) and game(s) == 'p2'])
- print([s for s in range(1, 150) if (s % 3 != 0) and game(s) == 'v2'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement