Session 13 of 13 · · 1 h 12 min

Perfect Shuffles

Perfect shuffles are a fascinating concept in both mathematics and card magic. There are two main types of perfect shuffles:

  1. In-Shuffle: The top and bottom halves of the deck are perfectly interleaved, with the first card from the bottom half becoming the top card of the shuffled deck.

  2. Out-Shuffle: The top and bottom halves of the deck are perfectly interleaved, with the first card from the top half remaining the top card of the shuffled deck.

Mathematical Properties

Perfect shuffles have interesting mathematical properties:

  • With a standard 52-card deck, 8 consecutive out-shuffles will return the deck to its original order.
  • With a 2n-card deck, the number of out-shuffles needed to restore the original order is related to the order of 2 modulo (2n-1).
  • In-shuffles and out-shuffles can be represented as permutations, making them useful for studying group theory.

Perfect shuffles are widely used in card magic because of their predictable patterns and the ability to control the position of specific cards in the deck.

Monge and Milk Shuffles

The Monge shuffle (also called the over/under shuffle) and the Milk shuffle (also known as the Klondike shuffle) are two other interesting shuffling techniques with mathematical properties.

Monge Shuffle

In a Monge shuffle, cards are placed alternately on top and bottom of the pile:

  • The top card is taken and held in the other hand
  • The next card is placed above it
  • The third card is placed below the first two
  • This pattern continues, alternating between placing cards on top and bottom

Milk (Klondike) Shuffle

The Milk shuffle involves taking pairs of cards from the top and bottom of the deck:

  • Take the top card, then the bottom card
  • Place them together on a new pile
  • Continue this process until all cards are in the new pile

Interesting Properties

  • The Monge and Milk shuffles are inverses of each other. Performing a Milk shuffle followed by a Monge shuffle (or vice versa) returns the deck to its original order.
  • Both shuffles have predictable cycle lengths depending on the number of cards in the deck.
  • These shuffles are useful in card magic for controlling the positions of specific cards.

Session notes

Chapter 6 closes the card-magic half of the book. We worked through how many perfect shuffles restore a deck, which permutations are reachable by mixing in- and out-shuffles, and how a binary encoding brings the top card to any position. Everything ran on a twenty-card demo.

1:01 The final session. We split 1–10 and 11–20 and interleaved them perfectly both ways: the original top card staying on top (out-shuffle) or the other half’s top card landing on top with the original tucked in (in-shuffle).

4:11 How many in-shuffles restore the order? The shuffle is a bijection, so the starting arrangement lies in its cycle – worth saying, since for a general deterministic operation on finitely many states it is not obvious. On 20 cards: six.

7:23 Out-shuffles on 20 cards took eighteen, counted laboriously; the deck looked nearly restored at the ninth or tenth but was off by one. For 52 cards the book gives 8 out-shuffles and 52 in-shuffles, which I quoted swapped while speaking; the authors say they found the 52 by actually performing the shuffles. No proof appears in the book.

10:29 Which permutations are reachable by mixing in- and out-shuffles? The book cites papers rather than proving this. A necessary condition: stay-stack symmetry is preserved. On 20 cards, pairs summing to 21 remain symmetric about the centre line under every shuffle, as we tracked on the demo.

14:16 A parity condition further cuts the reachable set by a factor of two or four, depending on whether the deck size is a power of two. For sizes like 52, 60, and 68, every symmetry-consistent arrangement is reachable. The exact statement is in the cited papers.

15:55 The book poses a puzzle: no sequence transposes the top two cards while fixing the rest, since it would break the symmetry of 1 and 4 with 2 and 3, with one exception. I have not found it.

17:01 To place the top card at position : write in binary, read left to right, 1 for in and 0 for out. Position 13 gives : in, in, out, out. Position 9 gives : in, out, out, out. Both checked on the demo.

21:52 Why it works, assembled in discussion. An in-shuffle sends position to , an out-shuffle to (Pratik). Reading the target backwards: odd means out, even means in; halve and repeat. This is the binary-conversion algorithm. Counting cards above the tracked card is the cleaner framing: out doubles that count, in doubles and adds one, and we want 12 above.

34:45 Bringing a given card to the top is solvable, but the sequence depends on deck size “in some mysterious way” and requires tables for non-power-of-two sizes; recent work at the time of writing.

36:54 Milk and Monge shuffles. Sunita’s observation from yesterday about reverse-perfect and perfect shuffles has an analogue here: milk and Monge undo each other. On 1–20, a Monge shuffle puts 19 on top and 20 at the bottom; milking off top-and-bottom pairs returns 1, 2, 3, … My implementation was buggy (pairs and overall order reversed). Shashi noted these make most sense for even deck sizes. Sunita has a written argument; it will be added here with her permission.

41:08 The faro betting-game stack (ace to king four times, alternating suits, Monge shuffles) I skipped: I could not parse the rules of faro.

44:02 Ten Monge shuffles restore 20 cards to order (Sunita confirmed); the variant with the second card going under took twelve. No closed form in the book that I found.

48:08 The chat settled the pronunciation: Monge, as in the French mathematician.

51:56 With Monge or milk shuffles alone, the top card cycles through few positions before repeating; reaching an arbitrary position probably needs a mix of shuffle types, and even then it is unclear. Sunita suggested a link to sorting algorithms.

54:47 The down-and-under elimination: top card down, next under, repeat; one card survives after moves. The survivor, the book claims, is at index , where is the largest power of two below . For this gives the second card. The first round removes odd positions, the next removes odd multiples of 2, so some doubling is expected, but I do not see why subtract-and-double. The book calls this easy.

1:02:46 Vinay has a calculation tracking card indices when twelve cards are dealt into piles, making the stay-stack invariance of dealing explicit; it will be added to the notes.

1:07:53 Wrap-up: this ends the card-magic half of the book; the remaining chapters cover other magic, juggling, and stories, recommended as bedtime reading.

1:10:01 Sunita, closing: the elimination formula explains the partner trick’s otherwise mysterious deck sizes of 4, 12, and 44. With 11 cards, ; doubled, that is the sixth card, exactly the partner five cards away.

To think about

  • Prove that an in-shuffle on cards sends position to and an out-shuffle sends it to , and deduce the recycling numbers 6 and 18 for 20 cards and 52 and 8 for 52 cards.
  • Find the one exception to the impossibility of transposing the top two cards while fixing the rest.
  • Prove the down-and-under survivor formula: the last card is at index , where is the largest power of two below .
  • Count the distinct arrangements visited by repeated Monge shuffles of 20 cards.
  • Write out why milk and Monge shuffles are inverses.

4 interactive demos from the original page are parked while the card-interactives library is built; the text above stands on its own.