• + 0 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")