My solution (which looks somewhat correct, so don't read unless you want it spoiled)
Day 0: Where all numbers are base 6 (240 in base 6 == 104)
d0 = last digit of barrel number (in base 6) d1 = second last digit of barrel number (in base 6)
Servant 0: drink if d0 == 0 or d1 == 0 Servant 1: drink if d0 == 1 or d1 == 1 Servant 2: drink if d0 == 2 or d1 == 2 Servant 3: drink if d0 == 3 or d1 == 3 Servant 4: drink if d0 == 4 or d1 == 4
At the end of the day, we will have at least 3 servants alive. (i.e. a maximum of 2 can die)
We now have 3 cases, depending on how many actually died:
- If no servants die, then d1 == 5, d2 == 5. It is barrel 55 (in base 6)
- If servant N dies, then d1 == N, d2 == 5 or d1 == 5, d2 == N. (note that the maximum barrel number is 104, so we can't have confusion between 105 and 5). So we have only two possibilities to test, which is easy with 3 servants alive.
- If servants N1 and N2 die, then d1 == N1, d2 == N2 or d1 == N2, d2 == N1. This gives us at most 4 possible barrels that could be poisoned [1,N1,N2], [1,N2,N1], [0,N1,N2], [0,N2,N1].
So at the end of day 1, we have at least 3 servants, and at most 4 possibilities to test for. Assign possibility 0, 1, 2 to remaining servants. If they all survive, then untested possibility is poisoned. Otherwise, it is obvious.