Advertisement
Pastehsjsjs

Untitled

May 11th, 2023
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | Source Code | 0 0
  1. from functools import lru_cache
  2.  
  3.  
  4. # +3;+6;*2
  5. def m(h, last):
  6. if last and last == 3:
  7. return (h + 6, 6), (h * 2, 2)
  8. elif last and last == 6:
  9. return (h + 3, 3), (h * 2, 2)
  10. elif last and last == 2:
  11. return (h + 3, 3), (h + 6, 6)
  12. else:
  13. return (h + 3, 3), (h + 6, 6), (h * 2, 2)
  14.  
  15.  
  16. @lru_cache(None)
  17. def f(h, last):
  18. if h > 40: return 'END'
  19. if any(f(x[0], x[1]) == 'END' for x in m(h, last)):
  20. return 'P1'
  21. elif all(f(x[0], x[1]) == 'P1' for x in m(h, last)):
  22. return 'V1'
  23. elif any(f(x[0], x[1]) == 'V1' for x in m(h, last)):
  24. return 'P2'
  25. elif all(f(x[0], x[1]) in ['P1', 'P2'] for x in m(h, last)):
  26. return 'V2'
  27.  
  28.  
  29. for S in range(2, 36 + 1):
  30. res = f(S, 0)
  31. if res and res == 'V2':
  32. print(res, S)
  33.  
  34. #20
  35. #17
  36. #6 8
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement