A course in seven sections

Magic & Math with Cards

Sixty short lectures and twenty-two card tricks to try on yourself and then take apart. Each trick works for a reason you can see, and once you see it you can perform it yourself.

Ten cards, alternating red and black. Deal a few into a second pile, then riffle the two piles together.

Pile A · the deck, top at left
A real, random shuffle each time. Why it never fails →
1

Try it

You are the spectator. You make every choice and the cards follow the real rules.

2

Lift the curtain

Step through what happened to the cards and see exactly why the trick cannot fail.

3

Take it to the table

Exact set-up and handling, so you can perform it for someone tonight.

The course

Sixty lectures in seven sections

Twenty-two performance lectures each come with a trick you can play here; the other thirty-eight follow the mathematics further. Sections build on one another, and every lecture lists what to watch first. New here? Start with the introduction.

Performance lecture, with a trick to play Mathematics lecture

Section 1

Basic Concepts

A shuffle can scramble positions while leaving a count untouched.

Lectures 01–03 · 1 trick

  1. Lecture 1, performance: Miraskill: order hidden inside a shuffled deck

    Deal a shuffled deck in pairs. The red–red pile and the black–black pile always tie.
    Play Miraskill
  2. Lecture 2, mathematics: What a shuffle actually does

    Distinguish identity, position and orientation, and compute cuts, reversals, deals, riffles and compositions on a labeled packet.
  3. Lecture 3, mathematics: The magician’s question: what cannot change?

    Formulate an invariant with an initial condition and legal moves, and distinguish proof, testing and counterexamples.
Section 2

Hummer Shuffles

Cut and turn two cards together as often as you like. Something refuses to mix.

Lectures 04–12 · 4 tricks

  1. Lecture 4, performance: Baby Hummer: four cards refuse to stay mixed

    Four cards, mixed by your own hands. Your card ends up as the one facing the other way.
    Play Baby Hummer
  2. Lecture 5, mathematics: Turning a packet is two operations

    Represent a turnover as order reversal plus face complementation and use that representation to audit card-state animations.
  3. Lecture 6, performance: Ten cards, always five face up

    Ten cards, cut and turned however you like. Turn over every second card, and exactly five end up face up.
    Play Always Five Face Up
  4. Lecture 7, mathematics: A proof in two lanes

    Prove Hummer face-count balance for 2n cards, identify the even-size hypothesis, and strengthen the statement using lane difference.
  5. Lecture 8, performance: The Lonely Card: the selection stands alone

    Cut and turn two at a time, then secretly turn one card over. It ends up the only one facing the other way.
    Play The Lonely Card
  6. Lecture 9, mathematics: An alternating background as an error detector

    Interpret alternating orientations as a two-pattern code, transport defects through legal moves, and state the limits of detection and recovery.
  7. Lecture 10, mathematics: All the states the spectator can reach

    Use a finite state graph to distinguish reachable arrangements from impossible targets, and derive the identity–position–orientation constraint.
  8. Lecture 11, performance: Royal Hummer: a royal flush emerges

    Twelve shuffled cards, nine of your leave-or-turn choices, and a royal flush comes out face down.
    Play Royal Hummer
  9. Lecture 12, mathematics: Design a Hummer routine that survives testing

    Design and audit a new Hummer-style colour-separation routine by stating its preparation, move family, invariant and finish.
Section 3

Order Matters

A deck arranged so that every short run of colours happens exactly once.

Lectures 13–27 · 4 tricks

  1. Lecture 13, performance: Five colours reveal five cards

    Tell me only the colours of five cards. I'll name all five.
    Play Five Colours, Five Cards
  2. Lecture 14, mathematics: Every short word, exactly once

    Define and verify a binary de Bruijn cycle, distinguish capacity from construction, and explain cyclic cuts and truncation failures.
  3. Lecture 15, performance: One rank, one suit, three revelations

    Name one card's value and the next card's suit. All three cards are named.
    Play One Rank, One Suit
  4. Lecture 16, performance: Your first performable colour-window routine

    Cut sixteen cards, deal four, and say only their colours. All four are named.
    Play Your First Colour-Window Routine
  5. Lecture 17, mathematics: From a card window to a directed edge

    Translate overlapping binary windows into edges of a directed graph and back without confusing vertices with edges.
  6. Lecture 18, mathematics: Euler tours: use every edge once

    Prove Euler-tour existence under directed balance and connectivity and apply it to de Bruijn graphs.
  7. Lecture 19, mathematics: Build your own de Bruijn deck

    Construct, verify and export an order-four de Bruijn card stack and matching decoder.
  8. Lecture 20, mathematics: More than two colours: suits as an alphabet

    Generalize window codes to larger alphabets while checking capacity, cyclic uniqueness and physical card supply.
  9. Lecture 21, performance: Gold & Silver: identify cards by relative order

    Point out the highest and the lowest of three cards, and all three are named.
    Play Gold & Silver
  10. Lecture 22, mathematics: Universal cycles: patterns beyond binary words

    Define universal cycles through explicit encoding rules and distinguish verified relative-order examples from unsupported generalizations.
  11. Lecture 23, mathematics: Locate yourself from a tiny picture

    Decode a position from a verified 2×2 binary patch while respecting toroidal boundaries, orientation and sensor shape.
  12. Lecture 24, mathematics: From card windows to DNA reads

    Assemble a clean toy DNA string from its exact multiset of overlapping 3-mers using a directed edge trail.
  13. Lecture 25, mathematics: When the same clues fit two sequences

    Distinguish compatible assembly, unique reconstruction and robustness using exact small counterexamples.
  14. Lecture 26, mathematics: Decode without a giant lookup table

    Decode the prepared packet using exact bit-to-card mapping and verified feedback rules, including the zero-state exception.
  15. Lecture 27, mathematics: Design review: make a decodable card miracle

    Design and exhaustively audit a complete prepared-packet observation protocol.
Section 4

The Gilbreath Principle

One honest riffle shuffle, and the order still survives in blocks.

Lectures 28–39 · 4 tricks

  1. Lecture 28, performance: A messy riffle, perfectly mixed pairs

    Deal some cards into a pile and riffle as messily as you like. Every pair from the top is still one red, one black.
    Play Perfectly Mixed Pairs
  2. Lecture 29, mathematics: Why reversing one packet matters

    Prove why reversal yields mixed aligned pairs.
  3. Lecture 30, performance: The deck becomes a lie detector

    Call out the colour of each card you look at, truthfully or not. The verdict is right every time.
    Play The Lie Detector
  4. Lecture 31, mathematics: Decode the hidden packet—and diagnose mistakes

    Derive and audit a complementary-packet decoder, including order changes and input errors.
  5. Lecture 32, performance: Four suits survive the shuffle

    Cut, deal some, riffle once. Every group of four taken from the top still holds one card of each suit.
    Play Four Suits Survive
  6. Lecture 33, mathematics: The general Gilbreath principle

    Prove the general Gilbreath aligned-block inventory theorem using prefix intervals and cumulative counts.
  7. Lecture 34, performance: The spectator deals the winning poker hands

    You split, riffle and deal twice. Hand 1 is a flush, hand 5 a straight, and the flush wins.
    Play The Spectator Deals Poker
  8. Lecture 35, mathematics: The ultimate invariant: prefixes are intervals

    Characterize Gilbreath deck-list permutations exactly by their consecutive-prefix sets.
  9. Lecture 36, mathematics: How much freedom does one riffle allow?

    Count distinct Gilbreath permutations and distinguish operation histories, compositions and sampling distributions.
  10. Lecture 37, mathematics: A deck meets a quadratic map

    Define and distinguish real quadratic critical orbits, exact periodicity, superstability and boundedness.
  11. Lecture 38, mathematics: Read an orbit as a permutation

    Construct inverse orbit-rank permutations and state the precise real critical-cycle/Gilbreath correspondence.
  12. Lecture 39, mathematics: The Mandelbrot connection, with the bridge visible

    Define the Mandelbrot parameter set, distinguish finite escape evidence from membership, and locate the exact real Gilbreath correspondence.
Section 5

Count Out and Transfer

Deal a few, drop the rest on top. Repeat, and the packet comes home.

Lectures 40–45 · 3 tricks

  1. Lecture 40, performance: Three Scoop Miracle

    Shuffle, remember the bottom card, and spell an ice-cream flavour three times. Your card rises to the top.
    Play Three Scoop Miracle
  2. Lecture 41, mathematics: Count, reverse, transfer

    Derive the COAT position map and prove the three-transfer block formula.
  3. Lecture 42, mathematics: Four transfers restore the whole packet

    Prove fourth-power identity and distinguish permutation order from individual orbit lengths.
  4. Lecture 43, performance: The spectator finds the middle card

    Spell any three words from the menu, keep the odd pile, and the last card left is the one you chose.
    Play The Middle Card
  5. Lecture 44, mathematics: Unequal counts can still cancel

    Prove restoration for alternating counts and construct a protected off-center region.
  6. Lecture 45, performance: Nine cards and a freely named card

    Remember the third of nine cards, name any card at all, and spell it twice. Your card is third again.
    Play Nine Cards, One Named
Section 6

Assorted Tricks

Base three, Fibonacci numbers and clock arithmetic, each hiding in a deal.

Lectures 46–51 · 3 tricks

  1. Lecture 46, performance: The 27-card trick: choose the destination

    Name a number from 1 to 27 and think of a card. After three deals, your card is at exactly that number.
    Play The 27-Card Trick
  2. Lecture 47, mathematics: A card position written in base three

    Derive the ternary target code, prove convergence after three adaptive rounds, and distinguish the 21-card version.
  3. Lecture 48, performance: Little Fibs: two cards from their sum

    Choose two of six cards and tell me only their total. I'll name both.
    Play Little Fibs
  4. Lecture 49, mathematics: Unique sums—and where they stop being unique

    Prove distinct-pair uniqueness for Fibonacci-style values, expose triple ambiguity, and decode four-card complements.
  5. Lecture 50, performance: Last cards match

    Choose which packet to rotate, eleven moves a round. Every discarded pair matches, and so do the last two cards.
    Play Last Cards Match
  6. Lecture 51, mathematics: Remainders, common multiples and matching cards

    Derive fixed-total matching from rotations and explain common multiples, coprime CRT and compatible noncoprime clocks.
Section 7

The Best Card Trick

Four cards, laid in a row, name a fifth that nobody has seen.

Lectures 52–60 · 3 tricks

  1. Lecture 52, performance: Four cards name the fifth

    Choose five cards. My assistant shows four. I name the fifth.
    Play Four Cards Name the Fifth
  2. Lecture 53, mathematics: Why the suit-and-clock strategy always works

    Prove the same-suit and short-clock-distance guarantees for every five-card hand.
  3. Lecture 54, mathematics: Six messages in three cards

    Encode and decode all six triple permutations with explicit total-order conventions.
  4. Lecture 55, performance: Hide the key card’s role

    Choose any five cards. Four in a row name the fifth, and no position is special.
    Play Hide the Key Card
  5. Lecture 56, mathematics: Why 24 orders are not the whole story

    Resolve the 24-versus 48 paradox and derive the 124-card counting upper bound while retaining compatibility.
  6. Lecture 57, mathematics: A smaller miracle: three cards from eight

    Model three-from-eight communication as a compatible matching and inspect a complete verified small code.
  7. Lecture 58, mathematics: Hall’s theorem explains the 124-card limit

    Prove 124-card attainability using Hall’s theorem and a regular compatibility graph.
  8. Lecture 59, mathematics: Build the 124-card encoder

    Construct and prove an explicit 124-card encoder using modular selection, label compression and permutation rank.
  9. Lecture 60, performance: The 124-card finale

    Five cards drawn from a deck of 124. Four shown, the fifth named.
    Play The 124-Card Finale