Kleber's [Best card trick](http://www.apprendre-en-ligne.net/crypto/magie/card.pdf) proceeds as follows: The mark (audience member) freely selects five playing cards from a standard deck of $52$ and passes these five to the magician's assistant. The assistant studies those cards, returns one *mystery card* to the mark, and places the remaining four *exposed cards*, face up, in a sequence on a table. The magician then enters, inspects the sequence of exposed cards, and then correctly announces the full identity of the mystery card.


The trick works through the clever use of mathematics. The five selected cards always contain at least one suit that is represented by two (or more) cards. The assistant will choose one of these as the mystery card, and another of the same suit to be the first in the sequence of exposed cards. Thus the magician learns the suit of the mystery card. 


Playing cards can be placed in a canonical order ($\clubsuit A, 2, \ldots K, \diamondsuit A, 2, \ldots K, $ etc.), and thus the three remaining exposed cards can be placed in $3!$ possible order sequences. Thus the assistant can signal six candidate card values, counting from the value of the first card (modulo 13). However, that approach alone will not cover all 12 potential card values. This issue is circumvented by the assistant being careful about *which* card of a pair with the same suit is given back and which is used as the first card in the sequence: use as the first card the one whose value is fewer than seven steps before the other of the same suit (modulo 13), which is the mystery card; that way the $3!$ possible steps ensure that the mystery card can be reached from the first card in the exposed sequence.


**Question 1**: How many four-card exposed sequences can arise in such tricks?


**Question 2**: How many sets of five selected cards have more than one acceptable sequence of exposed cards?




---


*Background*


The mark is free to choose any set of five cards, and there are of course ${52 \choose 5}$ ways to do this. Each such set of five is guaranteed to have *at least one* sequence of four visible cards. Moreover, according to the algorithm, each exposed sequence leads to a unique mystery card.


Even given these facts, not all $52!/48!$ conceivable exposed sequences of four cards will appear. For example, the sequence $2 \spadesuit\ 3\spadesuit\ 4 \spadesuit\ 5 \spadesuit$ will never appear, because the inference algorithm implies the hidden card is the $3 \spadesuit$, which is instead in the exposed sequence.


As @IlyaBogdanov points out in a comment, any set of five selected cards that has just one suit represented by two cards will have a unique exposed sequence, and because of the uniqueness of the inference method, these must be distinct sequences. The number of such cases is $4 {13 \choose 2} 13^3$.


The number of cases that have *two* suits, each represented by two cards is ${4 \choose 2}{13 \choose 2}{13 \choose 2} 13$, and each of these will have *two* distinct possible exposed sequences.


The trickier cases are when there is a single suit with $3$ or $4$ or even $5$ cards of that suit, and the mixture of $3$ cards in one suit and $2$ in another. The challenge is that the number of exposed sequences will depend upon the particular cards in the represented suit. For instance, even if all five cards are spades, there will be a different number of solutions in these two cases: $\{2 \spadesuit\ 4 \spadesuit\ 6 \spadesuit\ 8 \spadesuit\ 10 \spadesuit \}$ and $\{2 \spadesuit\ 3 \spadesuit\ 4 \spadesuit\ 5 \spadesuit\ 6 \spadesuit \}$.



Questions about "The best card trick"
The answer to **Question 1** is $52!/48! - 4 \binom{13}{2} \binom{50}{2}= 6115200$. 


That is, I claim that the number of $4$-tuples that *cannot* occur is $4 \binom{13}{2} \binom{50}{2}$. To see this, note that a $4$-tuple $(a,b,c,d)$ cannot occur if and only if the fifth card $e$ that $(a,b,c,d)$ signifies is among $\{b,c,d\}$. Note that there are $4 \binom{13}{2}$ choices for $(a,e)$. Finally, for each of the $\binom{50}{2}$ $2$-subsets $\{x,y\}$ of $[52] \setminus \{a,e\}$, there is a unique ordering $(b,c,d)$ of $\{ x,y,e \}$ such that $(a,b,c,d)$ signifies $e$. 


As Ilya Bogdanov points out in the comments, a $5$-set has a unique $4$-tuple if and only if it contains exactly one pair of cards of the same suit. The number of such $5$-sets is $4 \binom{13}{2}13^3$. Thus, the answer to **Question 2** is $\binom{52}{5}-4 \binom{13}{2}13^3= 1913496$. 


