You are viewing a single comment's thread. Return to all comments →
Python3 solution:
from functools import cache def permutationGame(arr): def is_increasing(remain): return all(remain[i] < remain[i+1] for i in range(len(remain)-1)) def new_perm(remain, removed): return tuple(e - 1 if e > removed else e for e in remain if e != removed) @cache def first_wins(remain): if is_increasing(remain): return False return any(not first_wins(new_perm(remain, e)) for e in remain) return 'Alice' if first_wins(tuple(arr)) else 'Bob'
Seems like cookies are disabled on this browser, please enable them to open this website
Permutation game
You are viewing a single comment's thread. Return to all comments →
Python3 solution: