Pastehsjsjs

Untitled

May 10th, 2023
772
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | Source Code | 0 0
  1. from functools import lru_cache
  2.  
  3. def m(h):
  4.     return  h + 1, h + 3, h + 7
  5.  
  6. @lru_cache(None)
  7. def f(h):
  8.     if h == 42:return 'END'
  9.     if any(f(x)=='END' for x in m(h) if x <= 42):
  10.         return 'P1'
  11.     elif all(f(x)=='P1' for x in m(h) if x <= 42):
  12.         return 'V1'
  13.     elif any(f(x)=='V1' for x in m(h) if x <= 42):
  14.         return 'P2'
  15.     elif all(f(x) in ['P1', 'P2'] for x in m(h) if x <= 42):
  16.         return 'V2'
  17.  
  18.  
  19. for S in range(1, 41):
  20.     res = f(S)
  21.     if res and res == 'V2':
  22.         print(res, S)
  23.  
Advertisement
Add Comment
Please, Sign In to add comment