STEM Lores

Puzzle Vault

How Many Ways Can 4 Letters All Go in the Wrong Envelopes? The Story of Derangements

Most people guess the chance is below one third. Count the shuffles and every letter goes wrong more often than that, with e hiding in the answer.

Short · 4 Letters, 4 Envelopes: Can All Go Wrong? #Shorts · Watch on YouTube ↗

There are 9 ways to put 4 letters into 4 addressed envelopes so that every letter lands in the wrong envelope, out of 4 × 3 × 2 × 1 = 24 equally likely ways in all. So if you shuffle blind, the chance that all of them go wrong is 9/24 = 37.5%, just above one third (33.3%). Most people guess lower. These total mix-ups are called derangements, and as the number of letters grows, the chance settles at 1/e ≈ 0.3679, where e is the same 2.718… that turns up in compound interest.

Counting the nine derangements

Call the letters A, B, C and D, and list what lands in envelopes A, B, C and D in order. So BADC means envelope A holds letter B, envelope B holds A, C holds D and D holds C: every envelope wrong.

A derangement of four letters can take only two shapes. (A single swap leaves two letters at home, and a loop of three leaves the fourth at home, so both are out.)

3 + 6 = 9. The video lights these nine up in a grid of all 24 arrangements.

Montmort’s game of thirteen

The puzzle began at the card table. In Treize (“thirteen”), a game Pierre Rémond de Montmort described, a dealer shuffles a 52-card deck and turns the cards over one at a time, calling “one”, “two” and so on up to thirteen. He wins if a card matches the number he calls, such as an ace on “one”; if none of the thirteen matches, he pays the other players.

Montmort, born in Paris in 1678, first considered the counting problem in his Essay d’analyse sur les jeux de hazard of 1708. He solved it in the second edition of 1713, and Nicolaus Bernoulli, his correspondent since 1710, solved it at about the same time. The wider question, how many shuffles leave exactly k matches, is called the problème des rencontres, and the no-match counts are known as rencontres numbers or de Montmort numbers. Leonhard Euler took it up in a paper written in 1779, Solutio quaestionis curiosae ex doctrina combinationum, listing the first ten or so terms and proving the two rules that generate them.

From 9/24 to 1/e

One of Euler’s two rules is Dn = (n − 1)(Dn−1 + Dn−2). Letter A goes into one of the other n − 1 envelopes, say k; then letter k either swaps back into A or it does not, and those two cases give the two terms.

Letters All arrangements All wrong Chance
3 6 2 0.3333
4 24 3 × (2 + 1) = 9 0.3750
5 120 4 × (9 + 2) = 44 0.3667
6 720 5 × (44 + 9) = 265 0.3681
7 5,040 1,854 0.3679
8 40,320 14,833 0.3679

The chance wobbles around one value and locks onto it almost at once. Inclusion and exclusion gives the exact chance as 1 − 1/1! + 1/2! − 1/3! + … ± 1/n!. For four letters that is 1 − 1 + 1/2 − 1/6 + 1/24 = 9/24. Run the series forever and it adds up to 1/e.

Did you knowFor one or more letters, the number of derangements is always the whole number nearest to n!/e. For four letters, 24/e ≈ 8.83, which rounds to 9.

The same count answers the hat-check problem, where no one gets their own hat back. With 8 people or 8 million, the chance of a complete mix-up stays at about 36.8%. For why e turns up in so many places, read why e is 2.718.

More than a third of the time, every letter goes wrong.

More stories from Math Lore

All stories →
6 min readWhy Is e = 2.718…? How Compound Interest Found the Number of GrowthNobody chose the number 2.718281828…; let growth feed on itself and it answers, in banks, in atoms, in luck and in a circle.3 min readThe Mutilated Chessboard Problem: Why 31 Dominoes Can't Cover 62 SquaresThe area matches exactly. The colors do not. A puzzle from a 1946 logic textbook shows how the right way of looking beats any amount of trial and error.6 min readWhy Are Primes the Atoms of Numbers? From Euclid's Proof to RSA EncryptionEvery whole number is built from primes in exactly one way. That fact is 2,300 years old, and it still guards the padlock in your browser.5 min readWhat Is the Square Root of −1 Really? Imaginary Numbers as a Quarter TurnMultiplying by minus one is a half turn. What happens twice to make that? A quarter turn, and a second dimension for the line to turn into.5 min readThe Basel Problem: How Euler Found π²/6 in the Sum of 1/n²There is no circle anywhere in the question, yet the answer is π² over 6. It took ninety years, a 28-year-old and a sine wave treated as an infinite polynomial.5 min readAre Some Infinities Bigger Than Others? Cantor's Diagonal Argument ExplainedHow do you compare two endless collections without counting them? Georg Cantor's answer led him to a shocking result, and to a paradise Hilbert refused to leave.

More from the Lores

Watch on YouTube ↗