The One-Flip Chessboard Puzzle: How 64 Coins Can Encode Any Square
The Puzzle That Seems Impossible
Sixty-four coins can encode any square on a chessboard because the squares can be numbered from 0 to 63 using six binary digits. By combining the positions of all heads-up coins with an operation called XOR, one person can change the board’s encoded value to any chosen square by flipping exactly one coin.
The classic setup sounds like a magician’s challenge. A warden places one coin on each square of a chessboard, with every coin showing either heads or tails in an arbitrary pattern. The warden secretly selects one square and reveals it to Prisoner A.
Prisoner A may flip exactly one coin. Prisoner B then enters, sees only the final arrangement, and must identify the selected square. The prisoners may agree on a strategy beforehand, but they cannot communicate during the challenge.
How can Prisoner A send one of 64 possible messages with a single flip?
The surprising answer is that the board already contains most of the information. Prisoner A does not create a message from scratch. Instead, one carefully chosen flip adjusts the message already encoded in the board.
Why One Coin Flip Is More Powerful Than It Looks
The first tempting thought is that a coin has only two states, so flipping one coin should communicate only a yes-or-no answer. That misses the most important detail: Prisoner A can choose which of the 64 coins to flip.
There are 64 possible actions. Since:
64 = 2 × 2 × 2 × 2 × 2 × 2 = 2⁶
the choice among 64 positions can represent six binary digits, or six bits. Six bits are exactly enough to label every square from 0 to 63.
The difficulty is that Prisoner B never saw the original arrangement. Simply flipping the coin on the secret square would not work because Prisoner B could not tell which coin had changed.
The prisoners therefore need a rule that gives every completed board one readable value—and makes flipping coin number n change that value in a predictable way.
Numbering the Board in Binary
The prisoners begin by agreeing on an orientation for the board and numbering its squares from 0 to 63. The exact order does not matter as long as both prisoners use the same one.
Each number has a unique six-digit binary form:
| Decimal | Six-bit binary | |---:|:---| | 0 | 000000 | | 1 | 000001 | | 2 | 000010 | | 3 | 000011 | | 5 | 000101 | | 42 | 101010 | | 63 | 111111 |
Binary uses only 0 and 1. Each place represents a power of two: 32, 16, 8, 4, 2 and 1.
For example:
42 = 32 + 8 + 2
42 = 101010 in binary
Numbering begins at 0 for an important reason. Square 0 acts as a special “do nothing to the encoded value” position. Its coin still flips physically, but because its label is 000000, it changes none of the six binary components used to read the board.
The Secret Operation: XOR
The solution relies on XOR, short for “exclusive or.” For a single binary digit, XOR produces 1 when the two digits are different and 0 when they are the same:
| A | B | A XOR B | |:-:|:-:|:---:| | 0 | 0 | 0 | | 0 | 1 | 1 | | 1 | 0 | 1 | | 1 | 1 | 0 |
XOR can also be applied digit by digit to larger binary numbers. For example:
001101
XOR 101000
-----------
100101
Unlike ordinary addition, there are no carries. An easy way to think about XOR is as a collection of light switches: a 1 toggles a switch, while a 0 leaves it alone.
Two properties make XOR perfect for this puzzle:
A XOR 0 = A
A XOR A = 0
It is also reversible:
(A XOR B) XOR B = A
Readers who want to explore the operation further can consult Wolfram MathWorld’s guide to XOR. XOR is commonly treated as addition modulo 2 and is closely connected to parity checking.
How the Board Stores a Number
To calculate the board’s current encoded value, the prisoners look only at the squares whose coins show heads. They XOR together the numbers assigned to those squares.
Suppose the heads-up coins are on squares 7, 12 and 25. The board’s value is:
7 XOR 12 XOR 25
Tails-up coins contribute nothing.
Why does flipping one coin behave so neatly? If coin n changes from tails to heads, its label is added to the XOR total. If it changes from heads to tails, its label is removed—but XORing the same number again removes it automatically because n XOR n = 0.
Therefore, no matter which way the coin turns, flipping coin n changes the board’s value in exactly the same way:
new value = old value XOR n
This is the mechanism that makes the feat possible. It is also an elegant use of parity, a puzzle-solving idea explored further in how even-and-odd patterns reveal impossible moves.
The One-Flip Strategy, Step by Step
Once the prisoners have agreed on the numbering system, the solution follows a short procedure.
Prisoner A calculates the board’s current value.
XOR together the labels of all heads-up coins.Prisoner A notes the target square.
Call the current valueCand the target squareT.Prisoner A calculates the required coin.
The coin to flip is:
F = C XOR T
Prisoner A flips coin F.
Prisoner B calculates the final board value.
XOR together the labels of all heads-up coins.The result is the target square.
The proof fits into one line:
new value = C XOR F
= C XOR (C XOR T)
= (C XOR C) XOR T
= 0 XOR T
= T
No guessing is involved. The result is guaranteed for every possible starting arrangement and every possible target.
What If the Board Already Encodes the Target?
If C already equals T, then:
F = C XOR T
F = C XOR C
F = 0
Prisoner A flips the coin on square 0. Because that square’s label is 000000, the board’s encoded value remains unchanged. The rule requiring exactly one physical flip is satisfied, yet the message stays correct.
A Smaller Example You Can Check Yourself
Imagine eight coins numbered 0 through 7. Because 8 = 2³, three binary digits are enough to encode any position.
Suppose the heads-up coins are on squares 1, 2 and 4:
1 XOR 2 XOR 4 = 7
The current encoded value is 7. Now suppose the secret target is square 5.
Prisoner A calculates:
7 XOR 5 = 2
So coin 2 must be flipped. It currently shows heads, so it changes to tails. The remaining heads are on squares 1 and 4:
1 XOR 4 = 5
The board now encodes the target perfectly.
Notice that Prisoner B does not need to know that the previous value was 7, which coin was flipped, or whether that coin changed from heads to tails. Prisoner B simply reads the final XOR total and announces square 5.
Another Way to See It: Six Overlapping Groups
There is a less compact but highly visual explanation. Divide the chessboard into six overlapping groups, one for each binary digit.
- Group 1 contains every square whose first binary digit is 1.
- Group 2 contains every square whose second digit is 1.
- Continue until all six positions are covered.
For each group, count whether it contains an even or odd number of heads. Even represents 0; odd represents 1. The six parity results form the board’s encoded number.
Flipping a coin toggles the parity of every group containing that square. Because each square has a unique six-bit membership pattern, one coin can toggle precisely the combination of groups needed to transform the current value into the target.
This visual method reveals the puzzle’s connection to error-correcting codes. In coding theory, overlapping parity checks can identify where a bit has changed. The chessboard puzzle runs a closely related idea in reverse: Prisoner A deliberately chooses a bit to change so that the resulting parity pattern carries the desired message.
For an animated exploration of the puzzle’s deeper information theory, see 3Blue1Brown’s impossible chessboard puzzle lesson.
Why This Puzzle Is Such an Amazing Feat
The one-flip chessboard puzzle is memorable because it overturns several natural assumptions. One flip appears tiny, a random starting board appears useless, and the lack of direct communication appears fatal. Yet all three obstacles disappear once the players agree on the right structure.
The feat also shares an important lesson with the 100 prisoners puzzle and its strategy against impossible odds: coordination can transform a hopeless-looking challenge. The participants do not need luck, secret signals or supernatural memory. They need a shared mathematical language.
Most importantly, the puzzle demonstrates that information can hide in relationships rather than individual objects. No single coin announces the answer. The message exists in the combined pattern of all 64 coins.
That is the real magic of the one-flip chessboard puzzle. A board that looks like a jumble of heads and tails is secretly holding a six-bit number—and with one perfectly chosen flip, that number can become any square you want.


