Thought Toys · Strategy & computation · Exhibit 56

Catch one error, miss the next

Flip one bit anywhere in a 7-bit codeword and this trick finds it and fixes it — no hesitation, no ambiguity. Flip a second bit, though, and it just as confidently "fixes" something. Just not the right thing — and it hands back a message that looks every bit as legitimate as the real one.

Bit positions 1–7, sent · received · corrected parity data flipped by noise changed by decoder

Try it
your turn — drag noise up to 2 and watch it lie

What you're seeing

Four bits of real message ride inside a 7-bit codeword, padded out with three parity bits — each parity bit a running XOR of a different, overlapping subset of the other positions. Send it down a noisy line, and the receiver recomputes those three checks on whatever actually arrived. Read together, the three checks form a number from 0 to 7: the syndrome. Flip zero bits and the syndrome comes back exactly 0. Flip exactly one, anywhere in the seven, and the syndrome comes back as exactly that bit's position — not "there's an error somewhere," but "it's this one, right here." Flip it back and the original 4 data bits are sitting there again, untouched.

Now push the noise slider to 2. The syndrome still comes back as some confident number between 1 and 7 — the decoder never shrugs. But that number is now, provably, the wrong position: fixing it doesn't undo the damage, it adds a third change on top of the two real ones, landing on a completely different 4-bit message that looks exactly as legitimate as the one that was actually sent. There is no warning light. The only way to know something went wrong is to already know what the message was supposed to be — which, out in the real world, is exactly the one thing you never have.

The rule, exactly. Data bits sit at codeword positions 3, 5, 6, 7; parity bits sit at the powers of two, 1, 2, 4, each one the XOR of every position whose binary index shares that bit. The three recomputed checks, read as a binary number syndrome = c1 + 2c2 + 4c3, are exactly 0 for a clean codeword and exactly the flipped position for any single-bit error — never anything in between, never a false alarm. This works because Hamming(7,4) is a perfect code: the 128 possible 7-bit strings split into exactly 16 non-overlapping neighborhoods of radius 1 (1 center + 7 one-flip neighbors = 8 words, and 16 × 8 = 128 with nothing left over), one neighborhood per valid codeword. A single flip can only ever land inside the true neighborhood; two flips can walk the word into a different codeword's neighborhood entirely, where it looks perfectly at home. Verified in node (improve/verify/56-hamming.js): across every one of the 16 possible messages, all 128 zero-or-one-bit-flip cases recover the exact original data, the minimum distance between any two codewords is exactly 3, and all 336 possible two-bit-flip cases decode to a different, wrong message — 0 accidental matches. Counter-example: a decoder that simply refused to "correct" anything at all would at least be honest about a 2-bit error — instead, every real Hamming decoder reports full confidence on both an already-correct answer and a silently wrong one, using the identical code path; that is precisely why systems that must survive 2-bit errors add one more overall parity bit (SECDED) — upgrading "silently wrong" to "detected, but no longer fixable."

Also in Strategy & computation: Why more processors stop helping →

All 23 in Strategy & computation
  1. 10The evolution of trust
  2. 23Sorting algorithms
  3. 24PageRank & the random surfer
  4. 25Huffman coding
  5. 26Dijkstra's shortest path
  6. 27Nash equilibria
  7. 33The learning-rate cliff
  8. 36A* pathfinding
  9. 37Braess's paradox
  10. 44Diffie–Hellman key exchange
  11. 45Preferential attachment
  12. 46Aliasing & the Nyquist limit
  13. 47The secretary problem
  14. 49Freeze too fast, stay stuck
  15. 51Cross one line, and its territory closes
  16. 56Catch one error, miss the next — you are here
  17. 57Why more processors stop helping
  18. 58Why a busy line explodes
  19. 59The set that's only sure when it says no
  20. 60The fit that memorizes instead of learns
  21. 61When the wire breaks, pick one
  22. 67Better at both, and still better off trading
  23. 69Everyone was consistent. The vote wasn't.

← the cabinet · Thought Toys — a cabinet of explorable explanations. Exhibit 56.