èƵ

It’s a kind of magic

Prepare to be amazed. Ian Stewart finds an old card trick with something new to offer mathematicians

IT IS, says mathematician Michael Kleber, “the best card trick there is”. The trick is not a new one – it was invented in the 1920s by the recipient of MIT’s first mathematics PhD, William Fitch Cheney, Jr. But, nearly 20 years after its inventor’s death, this mathematical illusion is stimulating new ideas in information theory, the backbone of cryptography and telecoms.

So, are you ready? Here’s an ordinary pack of cards, shuffled into random order. Please choose five cards from the pack, any that you wish. Don’t let me see their faces. No, don’t give them to me: pass them to my assistant Esmerelda. She can look at them.

Now, Esme, show me four of the cards. Hmmm … nine of spades, six of clubs, four of hearts, ten of diamonds. The hidden card, then, must be the queen of spades!

Tumultuous applause.

At first glance, it just seems impossible – especially to anyone who knows about information theory. To transmit information, you need to encode it in something that can be set in a variety of arrangements. For example, in the binary code used in computing and telecoms, specifying the number 8 requires a minimum of four binary digits, or bits: “1000”. And the same principle is true in this card trick. Here, though, the information is not transmitted via a specific ordering of zeros and ones. The only way to do it is by a specific ordering of the cards Esme presents.

But there’s a problem. There are only 24 ways to order four cards, so, according to information theory, Esme can only pass me one of 24 possible messages. So how can she tell me what that hidden card is of the 48 possibilities remaining?

Aha! Esme has a further option: she gets to choose which card remains hidden. With five cards, at least two must have the same suit. So Esme and I agree that whichever card she shows me first will have the same suit as the hidden card. Since she showed me the nine of spades, the hidden card will be one of the 12 other spades in the pack.

I’m gaining ground – or am I? Now there are only three cards that Esme can use to transmit information by selecting their order. And three cards can be presented in precisely six distinct orderings. So Esme is still unable to specify which of the 12 remaining possibilities is the hidden card. Somehow she has to reduce everything to six options. And she can.

Imagine all 13 spades arranged in a circle, reading clockwise in ascending numerical order, with ace = 1, jack = 11, queen = 12, king = 13. Given any two cards, you can start at one of them, move no more than six spaces clockwise round the circle, and get to the other one.

So all that Esmerelda has to do is make sure that the first spade she shows me is the one from which we can reach the other in six steps or less. Then she can use the three remaining cards to convey the necessary number by presenting them in a particular one of the six possible orderings. There are lots of ways to do this, but the easiest is probably to establish a code based on the cards’ relative numerical value. If any two carry the same number, they can be ordered by suit. The bridge system – clubs, hearts, diamonds, spades – would work.

The three cards she is looking at constitute a smaller value one (S), a bigger one (B), and one somewhere in between (M). By choosing the right order for the second, third, and fourth cards, say SMB = 1, SBM = 2, MSB = 3, MBS = 4, BSM = 5, BMS = 6, Esmerelda can tell me that crucial number between 1 and 6. Remember the five cards we started with: six of clubs, ten of diamonds, four of hearts, nine of spades, queen of spades. There are two spades, so my lovely assistant has to show me a spade first. Which one? Well, reading 9 – 10 – J – Q gets me from the nine to the queen in three steps, whereas Q – K – A – 2 – 3 – 4 – 5 – 6 – 7 – 8 – 9 takes more than six steps, so that’s no good. Esmerelda therefore shows me the nine of spades first.

Then she has to show me the remaining cards in whichever order is the agreed code for “3”. Using the code above, the correct order is six of clubs, four of hearts, ten of diamonds. Now I can count three steps on from the nine of spades, which takes me to the queen of spades. And that, ladies and gentlemen, is how it’s done.

It’s an interesting exercise in the principles of number theory, but perhaps not earth-shattering. So why are mathematicians so interested in this trick?

Well, picking 5 cards from 52 is what mathematicians call a special case. What happens with different numbers? Could you, for instance, pick the hidden card among 5 drawn from a pack of 100 cards? In a generalisation of the trick, suppose the pack contains p cards (still sticking with four suits) and we draw n of them. The assistant shows all but one of the n cards, and the magician works out the final one. How big can p be?

Information theory tells us that the trick is impossible if there are more hands of n cards than there are messages formed by n −; 1 of them. Doing the calculation, we find that p can be at most n! + (n − 1), where n! is shorthand for “n factorial”, equal to n × (n − 1) × … × 3 × 2 × 1. Work it out, and you find that you can – in principle at least – do the above 5-card trick using a pack of 124 cards. With 6 cards drawn, the pack can have up to 725 cards. Picking 7 cards, the pack can have 5046, and with 8 it can have 40,327.

The calculations show only that the trick is in principle possible with these numbers of cards – that there are enough possible messages to convey the information needed to specify the final card. But magicians need an actual method for doing the trick. This is where more complex information theory ideas (to be precise, the “marriage theorem” and the Birkhoff-von Neumann theorem) come in.

Kleber, of Brandeis University in Waltham, Massachusetts, has laid out his route to working out a manageable way to do the trick with 124 cards in a recent issue of The Mathematical Intelligencer (vol 24, p 9) and he can do it “quite smoothly”, he says. He also reveals that games expert Elwyn Berlekamp of the University of California, Berkeley, has worked out that there’s enough slack to perform an impressive variant. Berlekamp asks the volunteer to toss a coin as well as pick five cards. After the assistant has shown four cards, he not only predicts the fifth, he also tells the audience whether the coin was heads or tails.

OK, maybe it’s not the most important bit of maths in the world. It’s hardly a route to a theory of everything, and probably won’t revolutionise information transfer. But it does help mathematicians get to grips with important concepts of information theory. Indeed, there are a slew of papers in press about the trick and its variants, and how they expose the value of devising sensible coding methods. These ideas bridge the gap between “there must exist some way to do this” and “here’s a simple method that anyone can use”.

The trick also shows that the context in which you are seeking information has a subtle effect on how much information you actually need. It can even render the “impossible” possible. It’s like magic.

More from èƵ

Explore the latest news, articles and features