1000 bottles of wine, one is poisoned, one round of tasting: how many tasters do you need? Binary encoding, the log₂ n lower bound and Dorfman pooling, with a simulator and calculators.
A king has 1000 bottles of wine for a feast. Exactly one is poisoned, and the poison only takes effect after a while, so there is time for just one round of tasting. A taster may sip from as many bottles as they like. What is the minimum number of tasters that guarantees we find the poisoned bottle?
Answer: 10 tasters, because 210 = 1024 ≥ 1000, while 29 = 512 < 1000.
Number the bottles in binary from 0 to 999. Ten binary digits (bits) can represent every number from 0 to 1023, so 10 bits cover every bottle.
Give each taster one bit. Taster i drinks from every bottle whose i-th bit is 1. For example bottle 5 = 0000000101 is tasted by taster 0 and taster 2.
Wait for the poison to act. Exactly those tasters get sick whose bit is 1 in the poisoned bottle's number.
Read off the answer. Write 1 for every sick taster and 0 for every healthy one: the bit pattern you get is the poisoned bottle's number. If nobody gets sick, it was bottle 0.
bottle = b9·29 + b8·28 + … + b1·21 + b0·20, where bi = 1 if taster i got sick
After one round each taster gives one of exactly two outcomes: sick or healthy. With k tasters there are therefore at most 2k different outcomes, and every bottle needs an outcome of its own, otherwise two bottles could not be told apart. So 2k ≥ n must hold, which gives the information-theoretic lower bound:
k ≥ ⌈log2 n⌉
For n = 1000, log2 1000 ≈ 9.97, so at least 10 tasters are needed. The binary scheme uses exactly 10, so it is optimal.
Instead of testing items one by one, we test groups (pools) of them at once. A group's test is positive if it contains at least one defective item. The goal is to find the defective items with as few tests as possible.
In adaptive testing each test may depend on the earlier results, like a binary search that halves the suspicious bottles every round. That also needs ⌈log2 n⌉ tests, but one after another: 10 rounds for 1000 bottles. In non-adaptive testing every test is fixed in advance and run in parallel, which is exactly what the one-round wine puzzle requires.
The idea comes from economist and statistician Robert Dorfman. During the Second World War, US Army recruits were screened for syphilis by blood test. Dorfman suggested pooling the blood samples of several people and retesting individually only when the pool came back positive. When the disease is rare, this saves most of the tests.
If there are t rounds (and the poison acts within a round), a taster can get sick in round 1, 2, …, t, or never: t + 1 outcomes instead of 2. Number the bottles in base t + 1; digit d for taster i means “drinks from this bottle in round d” (0 = never). Then (t + 1)k ≥ n is needed, so k = ⌈logt+1 n⌉. For 1000 bottles and 2 rounds: 37 = 2187 ≥ 1000 > 36 = 729, so 7 tasters are enough.
With several poisoned bottles the problem gets much harder, and the binary trick no longer works directly: if bottles 1 (001) and 2 (010) are both poisoned, the sick pattern is 011, exactly what bottle 3 alone would produce. Designing tests that separate several defective items is a research field of its own (combinatorial group testing) and needs considerably more tests.
Dorfman's two-stage method is still in use: during the COVID-19 pandemic many laboratories pooled PCR samples to stretch their testing capacity. With g people per pool and prevalence p, the expected number of tests per person is:
E(g) = 1/g + 1 − (1 − p)g
The smaller p is, the larger the optimal pool and the bigger the saving; above roughly 30.7% prevalence pooling no longer pays off. In practice, dilution also lowers test sensitivity, so labs use smaller pools than the theoretical optimum.