We take the first barrel and give its contents to all five prisoners. If the first barrel is poisoned, they will all die within 12 hours.
We take the second barrel and give its contents to all prisoners except the first. If the second barrel is poisoned, the last four prisoners will die within 12 hours. The same applies to the third, fourth, fifth, and sixth barrels.
Then, we combine everything... The last barrel in this list will not be given to anyone, meaning if it is poisoned, everyone will remain alive (hooray!). How many barrels can we test this way? Using the formula:
C5^5 + C4^5 + C3^5 + C2^5 + C1^5 + C0^5, where Cx^y = y!/((y-x)!x!)
= 1 + 5 + 10 + 10 + 5 + 1 = 32
It's a modest result.
Two rounds in this case would be like having ten prisoners? But no... If someone dies in the first round, we can't use them in the second, unfortunately. However... why not take advantage of this and express it as a formula?
So, we take the first barrel and give it to all five... Do we need to repeat this in the second round? No, that's enough; we won't get any more information.
We take the second barrel and give it to four, excluding the first... In the next round, we can give it to the first one or not. We have two options. Accordingly, either four die, excluding the first, in the first round, and then the first dies, or four die, and the first doesn't. Thus, we can get two different results...
In total:
C5^5 * C0^5 + C4^5 * (C0^1 + C1^1) + C3^5 * (C0^2 + C1^2 + C2^2) + C2^5 * (C0^3 + C1^3 + C2^3 + C3^3) + C1^5 * (C0^4 + C1^4 + C2^4 + C3^4 + C4^4) + C0^5 * (C0^5 + C1^5 + C2^5 + C3^5 + C4^5 + C5^5) =
1 * 1 + 5 * 2 + 10 * (1 + 2 + 1) + 10 * (1 + 3 + 3 + 1) + 5 * (1 + 4 + 6 + 4 + 1) + 1 * 32 =
1 + 10 + 40 + 80 + 80 + 32 = 243
In total, we can test up to 243 barrels using these combinations.
Answer: yes
(^ is not an exponent, but a superscript)