nq1s788

19-21

Mar 4th, 2026
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. from functools import lru_cache
  2.  
  3. def moves(a):
  4.     return a + 1, a + 4, a * 5
  5.  
  6.  
  7. @lru_cache(None)
  8. def game(x):
  9.     if x >= 68:
  10.         return 'WIN'
  11.     if any(game(e) == 'WIN' for e in moves(x)):
  12.         return 'P1'
  13.     if all(game(e) == 'P1' for e in moves(x)):
  14.         return 'V1'
  15.     if any(game(e) == 'V1' for e in moves(x)):
  16.         return 'P2'
  17.     if all(game(e) in ['P1', 'P2'] for e in moves(x)):
  18.         return 'V2'
  19.  
  20.  
  21. def p19(x):
  22.     return any(game(e) == 'P1' for e in moves(x))
  23.  
  24. print([s for s in range(1, 68) if p19(s)])
  25. print([s for s in range(1, 68) if game(s) == 'P2'])
  26. print([s for s in range(1, 68) if game(s) == 'V2'])
Advertisement
Add Comment
Please, Sign In to add comment