The classic 21-card trick — a little mathematics, a little magic.
Think of a card. Point to its pile three times. Watch it appear.
Deal 21 cards into three piles of seven. The player silently picks a card and says only which pile it is in. Pick the piles back up with the chosen pile in the middle, deal again, and repeat.
Each round squeezes the card into a smaller part of the deck:
| Round | Where the card can be | Possibilities |
|---|---|---|
| Start | 1 – 21 | 21 |
| 1 | 8 – 14 | 7 |
| 2 | 10 – 12 | 3 |
| 3 | 11 | 1 |
After the third round the card is always the 11th in the deck. It is deduction, not a guess.
📺 Numberphile has a great explanation of the maths: 21 Card Trick
Play it here — nothing to install.
- Memorize any one of the 21 cards. Don't click it.
- Select I have my card.
- Choose the pile that contains your card, or press 1, 2, or 3.
- Do the same for the next two deals, then watch the reveal.
It works with mouse, touch, or keyboard, and has optional sound.
Run it locally
The game is plain HTML, CSS, and JavaScript with no build step. Open web/index.html directly, or serve the folder:
py -m http.server 8000 --directory webThen open http://localhost:8000.
The original terminal version. Requires Python 3.
py .\Pocus.pyRemember a card and enter its row number each time you are asked. The program suggests a card to follow, but any card works.
Run one automated game, where the program picks a card itself and checks that the reveal matches:
py -c "from Pocus import test_Pocus; test_Pocus()"The output is picked card, revealed card, Pass/Fail, final position:
9 of Clubs,9 of Clubs,Pass,8
pyHocuspocus/
├── Pocus.py # Terminal game and trick logic
├── Deck.py # Card and deck helpers
├── test-pocus.ps1 # PowerShell test runner
├── media/ # Screenshots
└── web/ # Browser game
├── index.html
├── styles.css
└── game.js



