240 barrels of wine

Puzzle:

You have 240 barrels of wine, one of which has been poisoned. After drinking the poisoned wine, one dies within 24 hours. You have 5 slaves whom you are willing to sacrifice in order to determine which barrel contains the poisoned wine. How do you achieve this in 48 hours?

Solution:

The number system we generally use is base 10, or decimal system. I am assuming that the reader is familiar with the ternary system (base 3) while reading this answer.

The pledge
Let the barrels be numbered from 1 to 240 (base 10)

——————–
3 | 240   | 0
3 | 80     | 2
3 | 26     | 2
3 | 8       | 2
3 | 2       | 2
3 | 0       |

Ans 240(base 10)  = 22220(base 3)

This means in base 3, they will be numbered from 00001 to 22220.

There are 3 digits in the ternary system, corresponding to 3 outcomes in the given problem for each slave. Assigning the digits to the outcomes,
Digit    Outcome
0          – the slave does not die
1           – the slave dies within the first 24 hours (00 to 24)
2           – the slave dies in the last 24 hours (24 to 48)

The turn
We give the wine from each barrel to the slaves, according to the following examples –
Barrel 139
If we take barrel number 139 (base 10) = 12011 (base 3)

3rd digit is 0, so don’t feed slave 3 from this barrel.
1st, 4th and 5th digits are 1, so feed slave number 1,4 and 5 from this barrel at time t=0.
2nd digit is 2, so feed slave 2 from this barrel at time t=24.

Barrel 231
If we take barrel number 231 (base 10) = 22120 (base 3)

5th digit is 0, so don’t feed slave 5 from this barrel.
3rd digit is 1, so feed slave number 3 from this barrel at time t=0.
1st, 2nd and 4th digits are 2, so feed slave number 1,2 and 4 from this barrel at time t=24.

The prestige
If we do that, then we can find which barrel is poisonous, based on which slaves die.
Example: If slave numbers 2 and 4 die in the first 24 hours, and slave 3 dies in the next 24 hours, then..
Barrel number 01210 (base 3)
That is, barrel number 48 (base 10) is poisonous.