Solitaire in Two Colors

Here's a simulation of a solitaire game of cards that does not require a table top [Ensley]:

The deck of cards is held face up and fanned through with the player removing pairs of cards of the same color whenever they occur adjacent in the deck. Of course, the removal of adjacent pairs may create other adjacent pairs which will also have to be removed. The game ends when there are no more adjacent same-colored pairs to remove. Winning the game means having no cards left at the end. This can be turned into a magic trick as follows:

The magician calls upon two spectators to each take half the deck of cards and shuffle them independently. They then merge their stacks (alternatively dealing the cards into a single stack) and play the solitaire game. To the amazement of everyone, they find they have won.

In the simulation, the two halves of a deck come in two different colors, red and blue, so that it is easy to see that the cards have been dealt alternately - a perfect shuffle. Cards themselves are represented by numbers from 1 through N, where N may be an even integer from a relatively broad range. The numbers are placed on a circle and removed by clicking on the pink circle between two adjacent numbers. One is allowed to remove numbers of the same parity: either both odd or both even.

If you are reading this, your browser is not set to run Java applets. Try IE11 or Safari and declare the site as trusted in the Java setup.

Solitaire in Two Colors

What if applet does not run?

To make sure that the magic trick works, the magician has to prepare the decks so that both contain the same number of black and red cards. In terms of the simulation, the four quantities: the numbers of odd and even numbers on the left and right must be equal. When the total quantity N of the numbers is a multiple of 4, that condition holds automatically. It is violated when N is even but is not divisible by 4.

To see why the trick works, note that the removal of adjacent numbers of the same parity satisfies three conditions:

  1. The difference OrOb between the number of odd red numbers and the number of odd blue numbers does not change.

  2. The difference ErEb between the number of even red numbers and the number of even blue numbers does not change.

  3. Blue and red numbers alternate.

Now, assume OrOb = ErEb = 0, to start with. Then a loss would mean that there remain a set of numbers alternately red and blue and alternately odd and even. This would imply that |OrOb| + |ErEb| is different from 0 in contradiction with our assumption.

(The argument is very much the same as was used with two color boxes placed in two rows.)


  1. D. E. Ensley, Invariants Under Group Actions to Amaze Your Friends, Math Magazine, Vol. 72, No. 5, December 1999, pp. 383-387.

|Contact| |Front page| |Contents| |Algebra|

Copyright © 1996-2018 Alexander Bogomolny