Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from functools import cache
- @cache
- def search(v: tuple[int]) -> bool:
- if all(x == 0 for x in v[:-1]) and v[-1] == 1:
- return False
- ans = True
- opponent_win = 0
- win_cnt = 0
- for i in range(len(v)):
- for x in range(v[i]):
- nv = tuple(min(x, val) for val in v[:i+1]) + v[i+1:]
- if all(val == 0 for val in nv):
- continue
- if search(nv):
- opponent_win += 1
- else:
- print(f"{v=} => {nv=}")
- win_cnt += 1
- return win_cnt != 0
- def main():
- v = (7, 7, 7, 7)
- print(f"{search(v)=}")
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement