This trick works because of two facts:
- When Alice draws a 5-card hand from a deck of cards, she must get at least two cards of the same suit.
- Think of a deck of cards as going from 1 (ace) to 13 (king) and put these numbers around a clock. The farthest apart any two cards can be is 6 steps, so long as you start on the correct card (it takes 7 steps to get from 13 to 7 but only 6 steps to get from 7 to 13).
Alice draws her hand and chooses two cards in the same suit. One of these is the "base" card and the other is the secret card. It must be possible to get from the base card to the secret card in 6 or fewer steps.
Alice shows Bob the base card. Now Bob knows the suit of the secret card, and he knows he has to count upward some amount from the base card to find the number of the secret card.
To tell Bob how much to count, Alice hands Bob her three remaining cards in the appropriate order:
low medium high - count up 1 step
low high medium - count up 2
medium low high - count up 3
medium high low - count up 4
high low medium - count up 5
high medium low - count up 6
If Alice has multiple cards with the same number, she orders those cards by suit. From lowest to highest, the suits go Clubs, Diamonds, Hearts, Spades.
Here are a couple of examples.
Alice draws: A clubs, 4 diamonds, 5 hearts, 6 spades, 7 spades.
Since spades is the only suit in which she has 2 cards, she has to use spades for the base card and the secret card. Since it takes only 1 step to go from 6 to 7, she shows Bob the 6 of spades as the base card.
Her remaining cards are A clubs (low), 4 diamonds (medium), 5 hearts (high). She shows Bob these cards in this order.
Bob knows he must step up 1 from the 6 of spades, so the secret card must be the 7 of spades.
Alice draws: K hearts, 4 hearts, 2 clubs, 2 diamonds, J spades.
Since hearts is the only suit in which she has 2 cards, the secret card and the base card must be hearts. The base card has to be the king of hearts, since we can get from K to 4 in 5 steps but it takes 9 steps to get from 4 to K.
The remaining cards are 2 clubs (low), 2 diamonds (medium), J spades (high). She needs to tell Bob to step up 5, so she shows him the cards in the order
J spades (high), 2 clubs (low), 2 diamonds (medium)
Bob knows to step up 5 from the king of hearts, so the secret card must be the 4 of hearts.