How 4 Cards Can Reveal 1 Out of 120

Choose 5 random cards out of a deck tell me 4 cards and I will guess the 5th one.

How do we squeeze information out of cards?

First, a spectator picks $5$ cards randomly out of a $52$-card deck and hands them to the magician's assistant. The assistant shows only $4$ of them to the magician, and the magician guesses the fifth one correctly.

Rules: Only information shared is the 4 cards. No cheating.

You can experience it yourself using the widget below. Click on $5$ random cards or hit "Deal Random 5".

Once $4$ cards are face-up, $52 - 4 = 48$ unseen cards remain, yet $4$ distinct cards can only be ordered in $4! = 24$ ways.

$48 > 24$, looks like we are missing a factor of 2 somewhere. But no everything looks fine. Then how does the magician guess the card??

Cracking the 52-card trick

Our naive count assumed the hidden card was chosen at random, but the assistant gets to CHOOSE which of the $5$ cards to hide. That single choice unlocks three simple combinatorial steps

  1. Pigeonhole Principle: With $5$ cards and only $4$ suits ($\clubsuit, \diamondsuit, \heartsuit, \spadesuit$), at least two cards must share a suit. Placing one of them first (the anchor) gives the magician the hidden card's suit for free.
  2. The 13-rank clock: Place the $13$ ranks ($A = 1, 2, \dots, K = 13$) around a circle. For any two cards of the same suit, the two clockwise distances between them sum to $13$. Since $13$ is odd, one clockwise gap is always in $\{1, 2, 3, 4, 5, 6\}$. Show the starting card first and hide the other so the offset is at most $+6$.
  3. Ordering the remaining 3: Before the trick, agree on a strict ranking of all $52$ cards (rank first $A \lt 2 \lt \dots \lt K$, breaking ties by $\clubsuit \lt \diamondsuit \lt \heartsuit \lt \spadesuit$). The remaining $3$ distinct cards always have a unique Low ($L$), Medium ($M$), and High ($H$) order, giving $3! = 6$ permutations to encode $+1$ through $+6$.

Try playing as the assistant in the trainer below. Click a repeated-suit card to hide, check the clock arc, and click L/M/H in order.

Pushing the Deck to Its Limit (N = 124)

What maximum deck size $N$ can work for ANY strategy (even ignoring suits). There are $\binom{N}{5}$ possible unordered $5$-card hands, and $P(N, 4) = N(N-1)(N-2)(N-3)$ distinct ordered $4$-card messages. Because no two different hands can send the same $4$-card message, the encoding must be one-to-one (injective):

$$\binom{N}{5} \le N(N-1)(N-2)(N-3)$$

Expand $\binom{N}{5} = \frac{N(N-1)(N-2)(N-3)(N-4)}{5!}$ and cancel $N(N-1)(N-2)(N-3)$ from both sides to get:

$$N - 4 \le 5! = 120 \implies N \le 124.$$

$120$ unseen cards fit into $4! = 24$ permutations: each $5$-card hand has $5$ choices of which card to hide, so each $4$-card set only needs to handle $\frac{1}{5}$ of its $120$ possible fifth cards ($120 / 5 = 24$). Slide $N$ from $52$ to $124$ (and break it at $125$) in the below widget.

Wait: Does N = 124 Actually Work?

Knowing $\binom{124}{5} = P(124, 4)$ only proves there are enough messages GLOBALLY. It does not guarantee we can pair every $5$-card hand with a $4$-tuple made ONLY of cards from that same hand.

Model the trick as a bipartite graph $G = (L, R, E)$:

A valid trick is a matching that covers every vertex in $L$.

Switch Widget 3 to "Toy Graph (t=2, N=3)" and click subsets $A \subseteq L$ to see Hall's condition $|N(A)| \ge |A|$ in action.

Hall's Marriage Theorem (a matching covering $L$ exists iff $|N(A)| \ge |A|$ for every subset $A \subseteq L$), proving it by counting edges:

For any subset $A \subseteq L$ with neighbor set $N(A) \subseteq R$, exactly $120|A|$ edges leave $A$, and at most $(N - 4)|N(A)|$ edges can enter $N(A)$:

$$120|A| \le (N - 4)|N(A)| \implies |N(A)| \ge \frac{120}{N - 4}|A|.$$

Whenever $N \le 124$, we have $\frac{120}{N - 4} \ge 1$, so $|N(A)| \ge |A|$ holds for every $A \subseteq L$—by Hall's Theorem, a strategy MUST exist at $N = 124$.

Hall's Theorem is purely an existence proof. Nobody can memorize a matching across $\binom{124}{5} = 225{,}150{,}024$ hands—so how do you actually perform $N = 124$ in your head?

Performing N = 124 Without a Lookup Table

Using Elwyn Berlekamp's explicit algorithm (popularized by Michael Kleber). Drop suits completely and label all $124$ cards with integers $0, 1, 2, \dots, 123$. Sort the spectator's $5$ chosen cards in ascending order: $c_0 \lt c_1 \lt c_2 \lt c_3 \lt c_4$.

  1. Choose which card to hide: Compute $s = (c_0 + c_1 + c_2 + c_3 + c_4) \bmod 5 \in \{0, 1, 2, 3, 4\}$, and hide card $c_s$.
  2. Re-index the 120 unrevealed cards List the $120$ cards NOT shown to the magician in increasing order, indexed $0$ through $119$. Because $c_0 \lt c_1 \lt \dots \lt c_4$ is sorted, exactly $s$ revealed cards are smaller than $c_s$. Removing those $s$ smaller cards shifts $c_s$ down to unseen slot: $$k = c_s - s \in \{0, 1, \dots, 119\}.$$
  3. The modular collapse (120 -> 24):

    Let $S_4$ be the sum of the $4$ revealed cards. By Step 1, $S_4 + c_s \equiv s \pmod{5}$. Subtracting $s$ and $S_4$ gives the key identity:

    $$k = c_s - s \equiv -S_4 \pmod{5}.$$

    Let $m \in \{0, 1, 2, 3, 4\}$ be the unique remainder satisfying $m \equiv -S_4 \pmod{5}$. Out of all $120$ unseen slots, ONLY the $120 / 5 = 24$ slots with $k \equiv m \pmod{5}$ remain possible.

  4. Encode the quotient: Compute $q = \lfloor k / 5 \rfloor \in \{0, 1, \dots, 23\}$ and arrange the $4$ revealed cards into the $q$-th lexicographic permutation (out of $4! = 24$).

Step through Steps 1 → 4 in Widget 4 below and watch the stride-5 comb isolate exactly $24$ candidate cells across the $120$-slot grid.

Decoding as the Magician

Walk through how the magician recovers the hidden card purely from the $4$ cards:

  1. Read the permutation rank $q \in \{0, \dots, 23\}$ from their order.
  2. Sum the $4$ cards to get $S_4$, and find the unique $m \in \{0, 1, 2, 3, 4\}$ with $S_4 + m \equiv 0 \pmod{5}$.
  3. Reconstruct the unseen slot $k = m + 5q$.
  4. Output the $k$-th card (0-indexed) in the sorted list of $120$ unrevealed cards— equivalently, start at $k$ and bump it up by $1$ for each revealed card that lies at or below it (checked in ascending order).

Beyond 5 Cards: The General Formula

What happens if the spectator picks $t$ cards ($t \ge 2$) and the assistant reveals $t - 1$ of them to encode the hidden card. Comparing unordered $t$-card hands against ordered $(t-1)$-card messages gives:

$$\binom{N}{t} \le P(N, t - 1) \implies \frac{N - t + 1}{t!} \le 1 \implies N \le t! + t - 1.$$

Point out that nothing special happened at $t = 5$:

What started as a parlor trick on $52$ cards turned out to be a tour through the Pigeonhole Principle, bipartite matchings, and modular arithmetic—all powered by one hidden degree of freedom: choosing what to leave out.