Advertisement
Uwwan

#23806

Apr 15th, 2022
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.09 KB | None | 0 0
  1. #23806
  2. from functools import lru_cache
  3.  
  4.  
  5. def moves(h):
  6.     # return h + 1, h + 3, h * 3
  7.     if h % 2 == 1:
  8.         return h * 3, h * 3
  9.     else:
  10.         return h + 1, h + 3
  11.  
  12.  
  13. # TODO: 1 - Xiao
  14. # TODO: 2 - Venti
  15. # TODO >=51; 1 bunch
  16. # TODO: moves:+1||+3||*3 ||if move is odd
  17. @lru_cache(None)
  18. def f(h):
  19.     # av_moves = [z for z in moves(h) if z != h and z % 2 != 0] #gates
  20.     av_moves = moves(h)
  21.     if h >= 51:
  22.         return 'END'
  23.     if any(f(x) == 'END' for x in av_moves):
  24.         return 'WIN1'
  25.     if all(f(x) == 'WIN1' for x in av_moves):
  26.         return 'LOSE1'
  27.     if any(f(x) == 'LOSE1' for x in av_moves):
  28.         return 'WIN2'
  29.     if all((f(x) == 'WIN1' or f(x) == 'WIN2') for x in av_moves):
  30.         return 'LOSE2'
  31.  
  32.  
  33. pmx = float('-inf')
  34. mx = float('-inf')
  35. fl = False
  36. for i in range(1, 60):
  37.     g = i
  38.     val = f(g)
  39.     """if val:
  40.        print(i, val)"""
  41.     if val == 'WIN2':
  42.         if fl == False:
  43.             mx = i
  44.             fl = True
  45.         elif i > mx:
  46.             pmx = mx
  47.             mx = i
  48.         elif i > pmx:
  49.             pmx = i
  50. print(pmx, mx)
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement