About Card Tricks
Three card tricks that work themselves: no sleight of hand, no secret moves, just arithmetic hidden inside an ordinary-looking deal. The page performs each one with you, then HOW IT WORKS shows the maths that makes it come out right every time.
- The Twenty-One Cards. Think of one of the 21 cards. Say which column it is in, three times over, and the page names it.
- The Kruskal Count. Secretly pick a number from 1 to 10 and count your way along a row of 52 cards by their values. The prediction, sealed before you started, is the card you finish on.
- Gilbreath's Shuffle. Deal as many cards as you like into a pile, riffle-shuffle the two halves together, and every pair off the top is one red and one black (or, with the suits version, every four holds one of each suit).
Keys: 1, 2, 3 pick a column in the 21-card trick. Nothing you choose leaves the page.
THE STORY
The 21-card trick is one of the oldest card tricks in print. It is usually traced to Claude-Gaspard Bachet's Problèmes plaisans et délectables (1612), a book of mathematical puzzles and pastimes, and it has been taught to children ever since. The mathematician Joseph Gergonne worked out the general rule in 1813: with any number of piles and cards, how many deals it takes and where the card ends up.
The Kruskal count is named after the American mathematical physicist Martin Kruskal (better known for his work on solitons), who came up with it in the early 1970s; the Russian mathematician Eugene Dynkin is said to have shown his students a similar counting trick before that. Martin Gardner described it in his Mathematical Games column in Scientific American, with court cards counting 5, as here. Mathematicians have since studied it as a "coupling" of random walks: two counts that have once touched stay together.
The Gilbreath principle is named after the mathematician and magician Norman Gilbreath, who published it in the magicians' magazine The Linking Ring in 1958; Gardner spread it further. The same idea works for any repeating cycle, such as the four suits. Persi Diaconis and Ron Graham give it a whole chapter of their book Magical Mathematics (2011).
The app grew from the Python scripts Deck of Cards.py (build a deck, shuffle it, deal a hand) and Cards.py (a pairs game whose cards flip over).
HOW IT WORKS
21 cards. The cards are dealt across in rows, so a card in row r (1 to 7) of a column sits r cards down that column. Gathering with your column in the middle puts seven cards above it, so your card goes to place 7 + r: somewhere from 8 to 14. Dealt again, places 8 to 14 can only land in rows 3 to 5, so the next gather puts your card at 10, 11 or 12, and the third at exactly 11. The answers don't tell the page anything it needs: the gathering does the work.
Kruskal count. Your count and the page's own (it secretly starts at card 1) hop about 5.4 cards at a time on average, so each lands on roughly one card in five. Once both land on the same card, they follow the same path from then on. Over 52 cards there are enough hops that they almost always meet. Almost: a plain shuffle brings a single chosen start onto the page's path about 85% of the time, and all ten starts together about 58%. So this page quietly deals again whenever a deal would fail for any start from 1 to 10 (HOW IT WORKS says so), and the prediction is never wrong. A magician with a real deck just accepts the odds.
Gilbreath. Dealing a pile reverses it, so the pile's top card and the rest's top card were neighbours in the deck: one red, one black. Each packet still alternates. Whichever packet the riffle drops from, after an even number of cards both packets again have opposite colours waiting, so the next two cards can't match. The same reasoning works for any repeating cycle, such as the four suits. One riffle only: shuffle again and it breaks. A single riffle is far from random; Shuffle Maths shows why it takes about seven.
The shuffles use the browser's random numbers. The riffle is the Gilbert–Shannon–Reeds model: each card falls from a half with chance in proportion to the cards left in it. The page's own test file checks every trick against every choice: all 21 cards, all ten starts on thousands of deals, and every possible riffle of smaller decks.
FURTHER WATCHING AND READING