## The Three-Pile Card Trick

December 13th, 2010 § 1 comment

This year at a holiday party Alex and I were at, a magician was making his way amongst the tables and performing some sleight-of-hand illusions as well as some classic mathematical card tricks. This afternoon, this video popped up in my Twitter feed:

Being almost done with finals for the semester I thought I’d take a few seconds and figure out how the trick works as a short exercise in reasoning.

First, some intuition: the trick works every time provided you follow the algorithm given. Therefore the three ‘chosen’ cards must be in the same place in the deck every time. This suggest the ‘cutting’ routine is for illusion only. The second half of the trick involves sequentially cards in odd ‘positions’ in the deck which suggests some relative primality.

Next, we prove to ourselves that the position of the chosen cards in the deck is deterministic. At the beginning we have four piles with sizes as follows:

$P_1 = 10, P_2 = 15, P_3 = 15, P_4=9$

We then add in the cards and cut the piles accordingly:

$P_1 = 10+C_1+\alpha, P_2=(15-\alpha)+C_2+\beta, P_3 = (15-\beta)+C_3+9$

So, after we combine the four piles, but before we move four cards from the top to the bottom of the pile, we can tell by simplifying that the sequence of cards from bottom to top is:

$10 \cdots C_1 \cdots 15 \cdots C_2 \cdots 15 \cdots C_3 \cdots 9$

If we count from the top to the bottom, after we have moved four cards from top to bottom, the three chosen cards will always be in positions 6, 22, and 38.

Now that we know what happens in the first half of the trick, we move onto the second part. It’s quite clear that the performer starts removing odd-positioned cards from the deck. So we need to show that positions 6, 22 and 38 have some special property that keeps them in the deck to the point where there are only three remaining cards. At first glance this seems unlikely. They are all even, to be sure, so they will pass the first round, but on second round, position 6 will be in position 3, so that card will get eliminated. Looking naïvely, there are of course positions that will survive four rounds of elimination, which are 16, 32, and 48, multiples of 2^4 or 16. These cards don’t occupy those positions.

It took me a moment to figure out what was going on here. Keeping the non-eliminated cards face down has the effect of reversing the deck, so the first card to be ‘kept’ will actually be in position 26 in the next round. When I worked the problem through a couple of times I dealt the cards to myself face-up to try and suss out which positions the chosen cards end up in. Of course, this breaks the trick completely.

Before the first pass, the chosen cards are in the following positions, and there are 52 cards in the deck.

$C_1 = 6 \\ C_2 = 22 \\ C_3 = 38$

After one round of elimination, with 26 cards in the deck

$C_1 = 24 \\ C_2 = 16 \\ C_3 = 8$

After two, with 13

$C_1 = 2 \\ C_2 = 6 \\ C_3 = 10$

After three with 6:

$C_1 = 6 \\ C_2 = 4 \\ C_3 = 2$

Finally after four eliminations and with three cards left:

$C_1 = 1 \\ C_2 = 2 \\ C_2 = 3$

Finally, then, the position p of a card after n rounds is given recursively by:

$\lceil \frac{52}{2n} \rceil - \frac{p_{n-1}}{2} + 1$

So that’s it. No magic, just some arithmetic.

### What's this?

You are currently reading The Three-Pile Card Trick at gdickinson.co.uk.