Nim - initial situation
Nim - initial situation

Nim is a combinatorial game for two players based on removing objects (usually matchsticks) from several heaps. In every turn the player may remove several objects from one heap (but always at least one, maximum number of removed objects differs according to rules of the given Nim variant). In a standard game the player, who takes the last object, wins. In an often played misère game loses the player, who takes the last object.

History of the game

Origins of Nim have not been completely clarified, but it is supposed that the game originated in China. First European references to this game are from 16. century. A winning strategy for Nim was proved and published by Charles L. Bouton in 1901 in the article Nim, a game with a complete mathematical theory.

Winning strategy

At first, we have to convert a number of objects (matchsticks) to the binary numeral system. Let's suppose that we have 3 heaps with 3, 4 and 5 objects. The player may remove at most 3 objects from exactly one heap.

3 = 011_{2} \\\\
4 = 100_{2} \\\\
5 = 101_{2} \\\\

Now we sum the binary sum sizes together, while neglecting carries from one digit to another (we perform XOR operation). The result is called nim-sum.

\\begin{array}{r l}
3 =&011_{2} \\\\
4 =&100_{2} \\\\
5 =&101_{2} \\\\
& 010_{2} \\\\

To get into the winning position, we must always make sure that the nim-sum is equal to zero. In this case, we have to perform such operation, which will set the middle digit to zero – we have to remove two objects from the first heap.

\\begin{array}{r l}
1 = & 001_{2} \\\\
4 = & 100_{2} \\\\
5 = & 101_{2} \\\\
& 000_{2}

It can be proved, that the opponent cannot turn the game – he cannot make the nim-sum equal to zero and if he takes any step, we will be able to reset nim-sum again.

Misère Nim modification

The winning strategy for misère game is almost the same. The only difference is in endgame, when there remain only heaps of size 1 – in this situation we remove objects in a way that there remains always an odd number of heaps (in standard game, there will always remain even number of heaps).


  • BOUTON, L. Charles. The Annals of Mathematics, 2nd Ser., Vol. 3, No. 1/4. (1901 - 1902), pp. 35-39.
  • Nim. In Wikipedia : the free encyclopedia [online]. St. Petersburg (Florida) : Wikipedia Foundation, 25 February 2002, last modified on 22 November 2010 [2010-11-27]. Available at WWW: <>. SEO od společnosti Digital Pylon

Online casino s algoritmem

České casino online online

Zajímavé články: Jak najít práci snů? Zvolte kariéru v IT!, Češi mají rádi hrací automaty online, Jak funguje algoritmické obchodování Casino, Online výuka Algoritmus a online marketing mají svá pravidla, Automaty, Matematický vliv, Ratings, Jak fungují algoritmy hazardních her online: více znalostí, více peněz, SYPWAI - nástroj pro vědecký vývoj, Vynikají na globálním trhu: Nejlepší vývojáři softwaru pro online výherní automaty, Jak si vybrat nejlepší české online casino, Proč byste měli hrát online casino VPN revoluce, Kde najdeme algoritmy v každodenním životě?