A great king has eight days to prepare for a party where he would like to serve wine. Of the many barrels of wine in the cellar, one is poisoned, but he doesn't know which one.

He checks his prison, and realizes he has only five prisoners that he can use to test the wine.

One sip of wine from the poisoned barrel will cause a prisoner to die within 24 hours. (For the purposes of this problem, assume that in this day and age prisoners are expendable)

With only eight days to go before the party, what is the largest number of barrels of wine he can have in his cellar, and still be able to determine with certainty which one has the poisoned wine in time for the party?

The answer is 59049.

**
This section requires Javascript.
**

You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.

For $d$ days and $p$ prisoners, the general solution to this type of problem is given by:

$N(d,p) = (d+1)^p = (8+1)^5 = \boxed{59049}$

I will try to put together a more detailed explanation as to why this is the case, but meanwhile please take a look at the solution provided by Arjen here for some insights. His solution can be extrapolated to any number of days and any number of prisoners.