We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
This is similar to the "Normal" nim game except for the case where all piles are '1'. We can take advantage of the fact that if all piles are '1' than the xoring of all piles will be '0' if there are even number of piles (Second player wins) and '1' if there are odd number of piles (First player wins). If not all piles are '1' we are back to the norma nim game (xoring of all piles).
Xor = bitwise xoring of all piles.
All1 = All piles are '1'
Misère Nim
You are viewing a single comment's thread. Return to all comments →
This is similar to the "Normal" nim game except for the case where all piles are '1'. We can take advantage of the fact that if all piles are '1' than the xoring of all piles will be '0' if there are even number of piles (Second player wins) and '1' if there are odd number of piles (First player wins). If not all piles are '1' we are back to the norma nim game (xoring of all piles).
Xor = bitwise xoring of all piles. All1 = All piles are '1'
So Xor ^ All1 will give the final result:
Can be done more efficiently, but less readable:
`