Section 7 · The Best Card Trick
The 124-Card Finale
Choose any five numbers from a deck of 124. My assistant hides one of your cards and lays the other four in a row. From that row alone, the magician names the hidden number.
Try it
Pick any five numbers. This page plays both partners: the assistant sees your whole hand, and the magician is handed only the final row of four.
Why it works
Once four of your numbers are on the table, 120 numbers remain unseen. Four cards can be laid out in only 4 × 3 × 2 × 1 = 24 orders, so the order alone could never single out one of 120. The assistant’s other freedom does the rest: choosing which of your five cards to hide.
The choice is made by arithmetic. Sort the five numbers and add them. The remainder on dividing by 5 says which card to hide: remainder 1 hides the smallest, remainder 4 the fourth, and remainder 0 the fifth. That choice guarantees something the magician can check without seeing the hidden card. Cross the four visible numbers off the line 1 to 124 and close up the gaps. In the shortened line of 120, the hidden card’s position always leaves the same remainder as 1 − (visible sum). Exactly 24 positions in that line have that remainder, one for each order of four cards.
The hidden card is chosen so that it always lands among 24 candidates the magician can list from the visible cards; the order of those cards says which of the 24 it is.
Step through the assistant’s worksheet below, for your own hand from Try it, the worked hand from the episode, or the boundary hand 1, 2, 3, 4, 5. The last step runs the magician’s worksheet on the row and checks that it returns the card that was hidden.
Why 124, and not 125?
Count both sides. A hand is a set of five labels; a message is an ordered row of four. With 124 labels there are C(124, 5) = 225,150,024 hands and 124 × 123 × 122 × 121 = 225,150,024 messages: exactly as many. Two different hands can never share a message, because the row plus the named card rebuilds the whole hand. With 125 labels there are 234,531,275 hands but only 232,593,000 messages, so some message would have to serve two hands, however clever the rule. That is the counting bound from episode 56.
Equal totals are not enough by themselves. A hand may only use rows made from its own cards, so a group of hands could be crowded into too few rows. Draw hands on the left, messages on the right, and an edge whenever a message uses four cards of a hand. For a group S of hands, its neighbours N(S) are the messages joined to at least one hand in the group, each counted once. If some group has fewer neighbours than members, no protocol can exist. Hall’s theorem says the converse also holds: if every group has |N(S)| ≥ |S|, then every hand can be given a message of its own.
Here every vertex has the same degree. A hand can hide any of its 5 cards and order the rest in 24 ways: 120 messages. A message can be completed by any of the 124 − 4 = 120 unseen labels: 120 hands. Take any group S. It sends out exactly 120 × |S| edges, all landing in N(S), where each message can take at most 120 (some of its edges may come from hands outside S). So 120|S| ≤ 120|N(S)|, which gives |S| ≤ |N(S)| for every group. No bottleneck anywhere, so a complete protocol exists. The arithmetic above is one explicit such protocol.
The graph has 225 million vertices on each side, far too many to draw. The same argument works on a graph small enough to see: three cards from a deck of eight, where the assistant hides one card and shows two in order (episode 57). Select hands and watch their neighbours.
The 56-row three-from-eight table on Hide the Key Card is exactly this page’s arithmetic with 3 in place of 5: hide position (sum mod 3), residue 1 − s mod 3, and two orders to choose between the two candidates. “Show one matching” below draws that table.
Challenge
Three tasks. Be the magician: the page deals a hand you never see and lays out the row, and you name the covered card with the magician’s worksheet. Be the assistant: hide a card and order the rest so that the magician, reading only your row, names it. Or predict the deck size at which every protocol must fail.
Perform it yourself
Set-up
- Make 124 cards numbered 1 to 124, with large clear numerals and identical, unmarked backs. There are no suits and no prepared order: the labels are the identities.
- Each partner carries the same fixed reference: the table of the 24 orders of 1234 in dictionary order, numbered 1 to 24, and a blank arithmetic worksheet. Keep an opaque cover for the hidden card.
- Agree the whole convention and do not change it: remainder 0 of the hand sum means the fifth card; residue 0 in the shortened line means positions 5, 10, 15, …; candidates and table rows are counted from 1.
- Rehearse with a partner until both worksheets are routine. The arithmetic may be visible as arithmetic; the surprise survives.
Performance
- The magician turns away. The spectator mixes the deck, chooses any five cards, shows them to the audience and hands them to the assistant.
- The assistant sorts the five, adds them and divides by 5. The remainder m (0 means 5) picks the card to hide: the m-th smallest. Cover it.
- The assistant adds the four visible cards (s), finds the hidden card’s position in the shortened line, h′ = h − (m − 1), the residue r = (1 − s) mod 5 (0 means 5), and the candidate number (h′ − r)/5 + 1. Then they lay the four cards out, left to right, in that row of the table (role 1 = smallest visible card).
- The assistant covers their worksheet before the magician turns back. Only the row of four crosses over.
- The magician copies the row in order before sorting anything, finds its row number in the table, the residue from the visible sum, the shortened-line position r + 5 × (row − 1), and restores the gaps.
- Name the number aloud, then ask the spectator to uncover the card.
Handling warnings. Record the order before you sort: the order is the message. When restoring gaps, compare each visible number with the updated value, and a number at or before it counts. Never improvise a new convention mid-performance; a decoder who treats remainder 0 as position 0 will name a plausible but wrong number.
Going deeper
The counting bound for any deck size
With N labels there are C(N, 5) = N(N − 1)(N − 2)(N − 3)(N − 4)/120 hands and N(N − 1)(N − 2)(N − 3) messages. Every hand needs its own message, so hands ≤ messages. Cancel the four common factors: (N − 4)/120 ≤ 1, that is, N ≤ 124. For an ordinary 52-card deck there are 2,598,960 hands and 6,497,400 messages, which is why the Fitch Cheney trick has room to spare.
Why Hall’s condition is enough
Take a matching of the largest possible size and suppose some hand u is unmatched. Explore from u: from a hand, follow any edge to a message; from a matched message, follow its matching edge back to its hand. If the exploration ever reaches an unmatched message, swap matched and unmatched edges along that path: one more hand is matched, a contradiction. Otherwise every reachable message is matched to a different reachable hand other than u, so the reachable hands outnumber their neighbours by one. Hall’s condition forbids exactly that.
The same recipe at every size
Hide one of k cards and show the other k − 1 in order. The counting bound becomes N ≤ k! + k − 1: 3 cards for k = 2, 8 for k = 3, 27 for k = 4, and 124 for k = 5. The same arithmetic works at every size: hide position (sum mod k), with 0 meaning k, use residue 1 − s mod k, and choose among (k − 1)! candidates by a permutation. For this page we ran the encoder and decoder on every hand for k = 2, 3 and 4, and on all 225,150,024 hands from the 124-card deck. The proof in episode 59 is what covers every hand; the checks catch slips in the implementation.
Existence versus a recipe
Hall’s theorem only promises that some complete assignment exists. Written out, a generic one is a table with 225,150,024 rows, which no assistant could consult at a table. The arithmetic code is a matching you can compute in a minute with a pencil. The counting bound says 124 cannot be beaten; Hall’s theorem says the containment rule does not lower that limit; the arithmetic shows how to reach it.
Sources
Norman Do, “A Mathemagical Card Trick” (Mathellaneous, Gazette of the Australian Mathematical Society), pp. 11–13: the 124-card bound, the Hall’s-theorem argument, and the explicit convention used here (hidden position = sum mod 5, compressed residue 1 − s).
Shai Simonson and Tara Holm, “Using a Card Trick to Teach Discrete Mathematics”, §4–5: the matching interpretation and a related explicit scheme with a shifted convention. Don’t mix the two conventions.
Michael Kleber, “The Best Card Trick”, The Mathematical Intelligencer 24(1), 2002: the five-card trick and its 124-card extension.
The five-card trick itself is credited to William Fitch Cheney Jr.; see Colm Mulcahy, Mathematical Card Magic, Chapter K. The three-from-eight table is an original checked teaching example from episode 57.