You are viewing a single comment's thread. Return to all comments →
Python (based on https://en.wikipedia.org/wiki/Nim#Proof_of_the_winning_formula )
def misereNim(s): nim_sum = 0 for val in s: nim_sum ^= val extra_moves = sum([1 for n in s if n > 1]) if extra_moves == 0: return "First" if len(s) % 2 == 0 else "Second" return "First" if extra_moves == 1 else ("Second" if nim_sum == 0 else "First")
Seems like cookies are disabled on this browser, please enable them to open this website
Misère Nim
You are viewing a single comment's thread. Return to all comments →
Python (based on https://en.wikipedia.org/wiki/Nim#Proof_of_the_winning_formula )