A king has 1000 bottles of wine, and exactly one has been spiked with a sleeping draught that takes exactly an hour to act. He has 10 tasters, each of whom may drink one mixture of any bottles he likes, and one hour: time for a single round and no second.
How should they drink, so that whoever falls asleep tells him which bottle it was?
Number the bottles 1 to 1000. A plan is a cup for each taster: the set of bottles poured into his mixture. An hour later a taster is asleep exactly when the spiked bottle was in his cup. So each bottle has its own pattern, the set of tasters whose cups it went into, and that pattern is what the king sees.
This is the film's first route. The cleanest way to see it is to count to : lay out slots to , put the bottles in slots 1 to 1000, and leave the other 24 empty.
The first taster drinks from the upper half, slots 512 to 1023. Whether he sleeps says which half the bottle is in. The second taster drinks the upper half of each half, so whichever half it turns out to be, he splits it again. The third drinks the upper half of each quarter, and so on: taster drinks the upper half of every block of width . After ten splits a block is one slot wide.
The halving looks as if it has to happen in turn, because the second question seems to depend on the first answer. It does not. The second taster's cup splits both halves at once, so it can be poured before anyone knows which half matters. Every cup is fixed in advance, all ten drink together, and the answers are read together at the end. For one bottle among many, asking all the questions up front costs nothing.
The film halves the 1000 itself, so its first taster drinks bottles 1 to 500. That works too: the halves have to be rounded, but ten rounded halvings still give every bottle its own pattern. Those cups are not the binary ones below, though: none of the ten matches a binary cup, or the reverse of one. The two routes give literally the same cups when the halving is done on the 1024 slots.
Hang on the tasters. Every whole number from 0 to 1023 is a sum of some of them in exactly one way, which is all that writing a number in binary means.
There is a one-line proof. Ten numbers have subsets, and every subset adds up to something from 0 to . Two different subsets cannot give the same total: look at the biggest number in one and not the other, . It outweighs all the smaller ones together, since . So 1024 subsets land on 1024 totals, one each.
Taster , wearing , drinks every bottle that has in its sum. If bottle is spiked, the sleepers are exactly the numbers in 's sum, so they add up to .
These are the halving cups. The upper half of a block of width is the numbers whose digit is 1, so the taster who splits blocks of width is the one wearing . Route one asks "upper half or lower?" ten times; route two writes the answers down as the digits of the bottle's number.
This one is not in the film. Write the plan as a table, a row for each taster and a column for each bottle, with a mark where the bottle goes into the cup. The column under a bottle is its pattern, so the plan works exactly when all 1000 columns are different. Nothing else matters.
The binary plan is the table whose columns are the bottle numbers written in binary. But any 1000 different columns of ten marks will do. There are working plans for ten tasters, a number with 2616 digits, and the film's is just the one you can read without a list.
The table also proves the coda. With nine rows there are only different columns, and 1000 bottles to give them to, so some two bottles share a column and the king cannot tell them apart. That is the whole of "why not nine". It even says how badly nine fail: at most 511 columns can belong to a single bottle, so at best the king can name the bottle for sure for 511 of the 1000.
The film follows bottle 643. In binary it is 1010000011₂, which is , so it goes into exactly 4 cups:
| Taster's number | In 643's sum? | After the hour | Digit |
|---|---|---|---|
| 512 | yes | asleep | 1 |
| 256 | no | awake | 0 |
| 128 | yes | asleep | 1 |
| 64 | no | awake | 0 |
| 32 | no | awake | 0 |
| 16 | no | awake | 0 |
| 8 | no | awake | 0 |
| 4 | no | awake | 0 |
| 2 | yes | asleep | 1 |
| 1 | yes | asleep | 1 |
Read the digits from the top and they spell 1010000011₂.
Here are all ten cups at once, as stripes across the cellar. This is the film's halving picture, each row cutting the cellar into twice as many blocks as the row above:
The same bottle, found by halving. Each round, the taster drinks the upper half of whatever is still possible (as well as the upper half of every other block at his level, which is why his cup is fixed in advance):
| Taster | He drinks | Then | Still possible |
|---|---|---|---|
| 512 | 512–1023 | asleep | 512–1023 |
| 256 | 768–1023 | awake | 512–767 |
| 128 | 640–767 | asleep | 640–767 |
| 64 | 704–767 | awake | 640–703 |
| 32 | 672–703 | awake | 640–671 |
| 16 | 656–671 | awake | 640–655 |
| 8 | 648–655 | awake | 640–647 |
| 4 | 644–647 | awake | 640–643 |
| 2 | 642–643 | asleep | 642–643 |
| 1 | 643 | asleep | 643 |
Halving the 1000 bottles themselves instead, with odd blocks rounded, the largest block left after each round is 500, 250, 125, 63, 32, 16, 8, 4, 2, 1. The film's on-screen count is that largest block, so round five reads 32.
Spike a bottle, wait the hour and add up the sleepers, or pick one yourself. Take a taster away and watch two bottles start to look the same.
| Taster | Drinks 643? | After the hour |
|---|---|---|
| 512 | yes | asleep |
| 256 | no | awake |
| 128 | yes | asleep |
| 64 | no | awake |
| 32 | no | awake |
| 16 | no | awake |
| 8 | no | awake |
| 4 | no | awake |
| 2 | yes | asleep |
| 1 | yes | asleep |
Any size of cellar. The fewest tasters for bottles is the smallest with , which is : the counting says no fewer will do, and the binary plan shows that many will. A thousand and twenty-four bottles still need only ten. One more needs eleven.
Maybe nothing was spiked. Then "nobody asleep" has to mean "nothing", and the bottles must leave that pattern alone: . The film's plan already does this, because it numbers the bottles from 1 and no bottle from 1 to 1000 has an empty sum. Up to 1023 bottles, ten tasters cover the case for free.
| Bottles | Exactly one spiked | Maybe none spiked |
|---|---|---|
| 2 | 1 | 2 |
| 10 | 4 | 4 |
| 100 | 7 | 7 |
| 512 | 9 | 10 |
| 513 | 10 | 10 |
| 1,000 | 10 | 10 |
| 1,023 | 10 | 10 |
| 1,024 | 10 | 11 |
| 1,025 | 11 | 11 |
| 2,000 | 11 | 11 |
| 1,000,000 | 20 | 20 |
More than one hour. Suppose there is time for rounds, and a taster who falls asleep stays asleep. Each taster's story is then one of : asleep after round 1, or 2, …, or , or never. That gives possible outcomes, and no plan, not even one that changes its mind as tasters drop, can tell apart more bottles than that.
The plan that gets there is binary with a bigger base. Write each bottle's number (less one) in base , one digit per taster. In round , every taster still awake drinks the bottles whose digit for him is . A taster who falls asleep after round has told you his digit is , and one who never sleeps has told you it is 0.
| Hours | Endings per taster | Fewest tasters | Patterns they give |
|---|---|---|---|
| 1 | 2 | 10 | 1,024 |
| 2 | 3 | 7 | 2,187 |
| 3 | 4 | 5 | 1,024 |
| 4 | 5 | 5 | 3,125 |
| 5 | 6 | 4 | 1,296 |
| 9 | 10 | 3 | 1,000 |
| 10 | 11 | 3 | 1,331 |
Two hours bring it down to 7 tasters, because . Ten hours, enough to take the film's halving one taster at a time, need only 3.
Nine tasters. Nine is not "almost enough". The binary plan cut down to nine sends bottle and bottle to the same cups, so 976 of the 1000 bottles share their pattern with another one and only 24 are named for sure. Bottle 643 looks exactly like bottle 131. A cleverer nine-taster plan can do better, but by the counting above never for more than 511 of them.
Two spiked bottles. Now the sleepers are everyone who drank either. Under the binary plan bottles 1 and 2 put tasters 1 and 2 to sleep, and so does bottle 3 on its own, and so do 1 and 3, and 2 and 3. The 499,500 pairs of bottles produce only 1013 different sets of sleepers. Counting still gives a floor: must be at least 499,500, so at least 19 tasters are needed, whatever the plan. Getting close to that floor is a real problem, and the subject of group testing.
None of the above is left to the proofs. scripts/bottles.mjs reads the film's own numbers and its own tastersFor from components/theme.ts, the file the episode is drawn from, and asserts that for every bottle from 1 to 1000 the page's plan sends the same tasters to sleep, that their numbers add up to the bottle, and that no two bottles share a pattern.
Halving. On 1024 slots, the ten halving cups are checked slot by slot against the ten binary cups, and they are the same. On the film's 1000 bottles, ten rounded halvings are checked to give 1000 different patterns, and none of the ten cups is a binary cup or the complement of one. Bottle 643's trace is run both ways.
Every way of filling the cups. For the tiny cellars where it can be listed, every possible plan is tried, 2,402,234 of them, and the ones that work are counted. The count matches , and is zero the moment there is one bottle more than there are patterns.
| Tasters | Bottles | Ways to fill the cups | Ways that work |
|---|---|---|---|
| 1 | 2 | 4 | 2 |
| 1 | 3 | 8 | 0 |
| 2 | 4 | 256 | 24 |
| 2 | 5 | 1,024 | 0 |
| 3 | 7 | 2,097,152 | 40,320 |
The rest. The base- plan is played out round by round for every one of the 1000 bottles at each number of hours in the table, and one taster fewer is checked to be too few. Every cellar size in the table is checked bottle by bottle, with and without "maybe none". All 499,500 pairs of bottles are tried for the two-bottle count.
The lab. The lab runs the functions in site/lib/bottles-core.mjs, the same text the script imports, and the script checks the pasted copy against the module. In 24,000 random spikings across the lab's cellar sizes and every number of tasters from 1 to 12, the spiked bottle is always among the bottles the sleepers point at, every one of those would have sent the same tasters to sleep, and whenever there are enough tasters the sleepers name exactly one.
11 tasters. Ten give only patterns, and eleven give 2048.
The tasters wearing 512 + 256 + 128 + 64 + 32 + 8: 6 of them. Halve 1000 repeatedly and the remainders give the same digits.
7 tasters. Each taster ends asleep after round one, asleep after round two, or awake: three stories, and is enough where is not. Write each bottle's number, less one, in base 3. In round one each taster drinks the bottles whose digit for him is 1, and in round two the ones whose digit is 2.
Tasters 1, 2 and 4 asleep, which adds up to 7. With exactly two spiked he cannot get further: 12 different pairs of bottles put exactly those three to sleep. He does at least know both bottles are among 1 to 7.