A deterministic card table

Eight Perfect Shuffles

A perfect out-shuffle is the opposite of random: it sends every position through a fixed doubling rule. Shuffle the live deck and watch all 52 cards return after eight exact out-shuffles, trace any card through the formula, then use binary in/out instructions to steer the top card to any requested position. A 24-card packet exposes the deeper surprise and a correction: its out-shuffle returns after 11, while the much larger group generated by both perfect shuffles is a cited theorem whose order arithmetic is checked live.

I · The returnCut exactly. Interlace exactly.

An out-shuffle splits the deck in half and alternates the cards while leaving the top and bottom cards outside the weave. Press once. The colors are original positions, so the interlacing is visible before the labels are readable.

Live 52-card deck

0 out-shuffles

top · position 0position 51 · bottom

Computing the return length…

Computing the position map…
Open the complete one-shuffle position map

Label positions from the top, starting at zero. For every card except the bottom one, the out-shuffle is multiplication by two modulo one less than the deck size. The bottom card is fixed separately. Repeating the shuffle repeats the multiplication. The deck returns when a power of two first leaves every position unchanged.

The in-shuffle changes which half contributes first. Its clean coordinate is one more than the visible position, so the modulus becomes one more than the deck size. Switch the control above and the page rebuilds the whole permutation. The longer return is not animated by assertion. You can run it.

II · The steering wheelWrite the destination in binary

The obvious dismissal is that eight is a cute coincidence about one deck size. Alex Elmsley's deeper observation turns the same doubling into control. Read a target's binary digits from left to right. A one means in-shuffle. A zero means out-shuffle. Each move appends that digit to the tracked card's position.

zero-indexed, top is 0

Binary instruction tape

Preparing the binary instruction…

Checking every possible target…

This is not a shortcut that works for only the displayed target. The green audit line exhaustively constructs and simulates the binary instruction for every legal target whenever the page loads. The offline verifier independently shuffles complete arrays, then asks where the original top card landed.

III · The exceptional packetTwenty-four cards do something else

The group generated by both perfect shuffles is much richer than the return time of either generator. A 24-card packet is an exceptional case in the classification by Persi Diaconis, Ronald Graham, and William Kantor. First, test the packet's plain out-shuffle.

The brief's suggested eight-shuffle test does not restore this packet. The modulus is 23. The page computes the residue after eight and keeps going to the first actual return. This is a useful correction: the famous count belongs to 52 cards, not to perfect shuffles in general.

Live 24-card packet · out-shuffle only

0 shuffles

Computing…

Computing the packet return…

Now add the in-shuffle and consider every arrangement reachable by any finite word in the two moves. That set is the shuffle group. Diaconis, Graham, and Kantor identify the 24-card case as a semidirect product involving the sporadic simple Mathieu group M12. The identification is their theorem. The live arithmetic below checks the resulting order, not the theorem that names the group.

Cited structure211 : M12 M12 orderComputing… Shuffle-group orderComputing…

Computed here

The two position permutations, their return times, every Elmsley landing, both 24-card residues, and the multiplication of the cited factors.

Cited, not reproved

The identification of the 24-card shuffle group with 2^11 : M12, and the published order of M12.

The check · rebuilt in this browser

These rows are filled only after the page constructs the permutations and runs the finite checks. The same algorithms live in the dependency-free Node verifier.

52-card out
Computing…
Out cycles
Computing…
52-card in
Computing…
Elmsley
Computing…
24-card correction
Computing…
Group arithmetic
Computing…

Uncertainties and free choices

Sources and reproducibility

Repository check: node research/eight-perfect-shuffles/verify-eight-perfect-shuffles.mjs. It rebuilds the permutations, decomposes every out-shuffle orbit, simulates all target instructions on full decks, and fails on any mismatch.