Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #23806
- from functools import lru_cache
- def moves(h):
- # return h + 1, h + 3, h * 3
- if h % 2 == 1:
- return h * 3, h * 3
- else:
- return h + 1, h + 3
- # TODO: 1 - Xiao
- # TODO: 2 - Venti
- # TODO >=51; 1 bunch
- # TODO: moves:+1||+3||*3 ||if move is odd
- @lru_cache(None)
- def f(h):
- # av_moves = [z for z in moves(h) if z != h and z % 2 != 0] #gates
- av_moves = moves(h)
- if h >= 51:
- return 'END'
- if any(f(x) == 'END' for x in av_moves):
- return 'WIN1'
- if all(f(x) == 'WIN1' for x in av_moves):
- return 'LOSE1'
- if any(f(x) == 'LOSE1' for x in av_moves):
- return 'WIN2'
- if all((f(x) == 'WIN1' or f(x) == 'WIN2') for x in av_moves):
- return 'LOSE2'
- pmx = float('-inf')
- mx = float('-inf')
- fl = False
- for i in range(1, 60):
- g = i
- val = f(g)
- """if val:
- print(i, val)"""
- if val == 'WIN2':
- if fl == False:
- mx = i
- fl = True
- elif i > mx:
- pmx = mx
- mx = i
- elif i > pmx:
- pmx = i
- print(pmx, mx)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement