The Poisoned Wine Bottles and Binary Encoding
With 1,000 bottles of wine, one poisoned, and a small number of tasters who each report only 'sick' or 'fine' after one tasting round, binary encoding finds the poisoned bottle using only about ten testers — because each taster is really answering one bit of a binary address.
Prerequisites: Thinking in a Different Base
You have 1,000 bottles of wine. Exactly one is poisoned. You have some number of test rats: each rat drinks from any subset of bottles you choose, and dies (eventually, all at the same known time) if and only if it drank from the poisoned bottle. You must identify the poisoned bottle using as few rats as possible, with everyone drinking simultaneously and just one round of testing. How many rats does it take? The answer is 10 — far fewer than the 1,000 a naive one-rat-per-bottle approach would suggest, and the mechanism is exactly binary encoding.
The core idea: number every bottle in binary, one rat per digit
Since , every bottle from 1 to 1000 can be written as a unique 10-digit binary number, using 0s and 1s. Assign rat (for ) to drink from every bottle whose binary label has a 1 in position . After the tasting, look at which rats died: the pattern of dead and alive rats, read as a binary number (dead = 1, alive = 0), is the binary label of the poisoned bottle — because the poisoned bottle is the unique bottle that was drunk by exactly the rats that died, by construction.
Each rat isn't answering "did you drink the poisoned bottle" in isolation — it's answering "is there a 1 in this specific digit of the poisoned bottle's address," and 10 such yes/no answers are exactly enough to spell out any address up to 1,023.
Worked example: a small version with 8 bottles
Label bottles 1 through 8 with three-bit binary addresses (using through , or equivalently 1 through 8 shifted by one): (using for the 8th bottle, treating it as address zero). Use 3 rats since . Rat A drinks bottles with a 1 in the ones-place (), Rat B drinks bottles with a 1 in the twos-place (), Rat C drinks bottles with a 1 in the fours-place ().
Suppose bottle 6 is poisoned, with binary address . Rat C drinks from bottle 6 (since has a 1 in the fours-place) and dies. Rat B drinks from bottle 6 (1 in the twos-place) and dies. Rat A does not drink from bottle 6 (0 in the ones-place) and survives. Reading the outcome as (C, B, A) = (dead, dead, alive) = — exactly the poisoned bottle, recovered directly from which rats died without ever testing a single bottle in isolation.
Binary encoding turns "identify 1 item out of " into "answer independent yes/no questions simultaneously," because every integer up to has a unique binary address, and each tester can be assigned to probe exactly one digit of that address across all candidates at once.
What this means in practice
This puzzle is a hands-on introduction to why shows up everywhere information needs to be pinned down efficiently — the same idea underlies error-correcting codes, hash-based reconciliation of large trade blotters, and any scheme that needs to identify one discrepancy among thousands of records without checking every record one at a time. Recognizing "this is a binary search over the test design, not over the data" is the transferable move: instead of testing bottles one at a time (linear in ), you're testing properties of bottles (linear in ).
It's easy to think more rats is always safer. It's not needed and not free — every rat is a resource (and in the real-world version, a life), and the minimum is fixed by the information-theoretic floor : fewer than 10 rats provably cannot distinguish 1,000 possibilities in one round, no matter how cleverly they're assigned.
Related concepts
Practice in interviews
Further reading
- Winkler, Mathematical Puzzles: A Connoisseur's Collection, ch. 2