Here’s an interesting puzzle which was part of the application for SPARC 2016. (Applications are now closed)

Suppose you have 240 cookie jars, one of which has been poisoned, so all the cookies in it are poisonous.

You also have 5 grey pigeons, each of which is immune to the poison, but has an interesting property: if it eats even a tiny crumb from a poison cookie, it will turn white at exactly 9am the following day, and stay white forever. The pigeons also have hearty appetites, and will immediately eat anything you put in front of them (which could include mixtures from multiple jars).

It is currently 8am, and you’re hosting a huge party at 10am the day after tomorrow (50 hours from now). You’d like to serve out as many cookie jars as possible while knowing, with certainty, that they are non-poisonous.

How many cookie jars is that, and how do you know? To get full credit, you should state the maximum, explain a strategy that achieves the maximum, and then explain why the strategy is optimal. (Partial solutions that establish a large number of safe cookie jars but not the maximum will also be considered. Solutions that make erroneous arguments will be penalized, so it is better to submit a correct partial solution than an incorrect full solution.)

My Kinda Elementary but Long-winded Solution
Samyak’s Streamlined Solution
Multinomial Digression

My Solution

We shall use a binary encoding. Suppose we had only $32 (=2^5)$ jars. Then we could use five birds to find the poisoned jar in one go.

Like this: Number the jars in binary.

So

$1 = 00001 = 1 \times 2^0$
$2 = 00010 = 1 \times 2^1$
$3 = 00011 = 1 \times 2^1 + 1 \times 2^0$

$18 = 10010 = 1 \times 2^4 + 1 \times 2^1$

all the way to $32 = 100000$.

Now we shall name our birds One, Two, Four, Eight and Sixteen. If a jar has a one in the units place, we feed it to One. If it has a one in the two’s place, we feed it to Two. And so on. So jar number 18 = 10010 will be fed to Sixteen and Two because it has ones in ones place and the sixteens place. Jar no. 32 won’t be fed to any pigeon, because it’s got no ones in places One to Sixteen.

Then we wait and see which pigeons turn white.

We add up the numbers of the pigeons and that tells us the number of the jar. Say pigeons Two and Sixteen turn white. Then the poisoned jar must be 18 because that was the only jar fed to Two and Sixteen and nobody else. Of course, if no pigeons turn white, it must have been jar 32.

Clearly, with $n$ pigeons, this method can differentiate $2^n$ jars.

We shall divide our 240 jars into 32 batches. These batches will have different numbers of jars in them so that even though some pigeons will have become white, the number of jars in the batch will be small enough that we can use the remaining pigeons and the second day to identify the single poison jar.

Batch number 31 is binary 11111, so if it’s poisoned all our pigeons are white and we can’t do anything more. So batch 31 can have only one jar.
The five batches with one zero in binary (15, 23,27,29,30) leave one pigeon still grey, so we can have ($2^1$ ) two jars in each of those batches.
The ten ($^5C_2$) batches with two zeros can have four jars each.
The ten ($^5C_3$) with three zeros can have eight jars each.
The five ($^5C_3$) with four zeros can have sixteen jars each.
Batch number 32 wasn’t fed to any pigeons, so all of them will stay grey if it’s the one, so we can have 32 jars in it.

$1+5+10+10+5+1=32$, so that’s all the batches we can test. Have we managed to put 240 jars in them?

$1 \times 1 + 5 \times 2 + 10 \times 4 + 10 \times 8 + 5 \times 16 + 1 \times 32 = 243$.

More than enough! (We can simply put 29 jars in batch 32 instead of 32)

Now take your 239 safe jars and party!

Samyak’s Streamlined Solution

Each bird will do one of three things: Stay grey, turn white after the first day, or turn white after the second day. Write numbers from 1 to 240 on the jars in ternary (base-3) All numbers less than (243=3^5) have five digits or less in base three. Ternary uses only the digits 0,1, and 2. If a jar has a one in the first place value, feed it to the first bird on day one. If it has a two written, feed it to the first bird on the second day. If a zero, don’t feed it to the first bird. Similarly for the other place values and the other pigeons. Using the birds’ ternary place values, add one in the correct place for each bird that turns white on the first day and two for each bird that turns white on the second day. The number you finally get is the number of the poisoned jar.

Multinomial digression

Consider $(1 +(x +y))^5$.

Expanding the multinomial gives $1 + ^5C_1 1^4(x+y) + ^5C_2 1^3(x+y)^2 + ^5C_3 1^2(x+y)^3 + ^5C_4 1^1(x+y)^4 + ^5C_5(x+y)^5$

Now substitute $x=1, y=1$.

We get $(1+1+1)^5 = 1 \times 1 + 5 \times 2 + 10 \times 4 + 10 \times 8 + 5 \times 16 + 1 \times 32 = 243$ , identical to the expression for number of jars in the first solution. I have a feeling that there is some way to translate from ternary to the trinomial to products of binomial coefficients, to the technique I used in the first solution, but I don’t know how, so I leave it up to you.