This problem has been asked and discussed in following posts:
- Logic problem: Identifying poisoned wines out of a sample, minimizing test subjects with constraints,
- Finding 2 poisoned bottles of wine out of a 1000
- Identifying poisoned wines
There are better optimized solutions to this problem. But, for easy comprehension, I formulated following solution with 6n tests (for $2^n$ wines). Are there any loop holes in it?
Part-I
Let's say there are $2^5$ (=32) wines. Represent them using binary system using 5 bits:
A-B-C-D-E
Give wines with A=$0$ to one person. Give wines with A=$1$ to another person. Do such tests for all bits (10 tests). Let's say you got a result like the following:
(0|1)-(0)-(1)-(0|1)-(0|1)
Bits B&C have fixed values (B=$0$. C=$1$). Bits A,D,E have two probable values each. The solution must be one from the following enumerations (Two solutions if you count both (a,b) and (b,a)). We represent the solutions in binary/decimal forms for clarity. It is easy to prove that they are just pairs of numbers with a constant sum (=27 in our case).
(00100, 10111) = (4,23)
(00101, 10110) = (5,22)
(00110, 10101) = (6,21)
(00111, 10100) = (7,20)
(10100, 00111) = (20,7)
(10101, 00110) = (21,6)
(10110, 00101) = (22,5)
(10111, 00100) = (23,4)
Part-II
Renumber the wines from (0,1,2,3,4,5 ...) to (0,1,4,9,16,25 ...) and put them into a bigger set of size $(2^5)^2$=$2^{10}$=1024 (We are squaring the numbers). Only 32 of the 1024 will be actual wines. Fill the rest of them with water.
Repeat the tests similar to that ones from Part-I on this bigger set (2*10=20 tests). This will give another set of solutions. Ignore all the solutions which contain water in one or both the bottles. Only the pair that matches with the corresponding pair from Part-I will be the actual solution (Two solutions if you consider duplicates).
If you get these from Part-I: $$(a,b),(c,d),(e,f),(f,e),(d,c),(b,a)$$ and if you get these from Part-II: $$(a^2,b^2),(g^2,h^2),(c^2,i^2),(i^2,c^2),(h^2,g^2),(b^2,a^2)$$
then the solution must be (a,b).
The reason is: Part-I satisfies $x+y=c1$, and Part-II satisfies $x^2+y^2=c2$. Given that x>=0 & y>=0, there is only one solution that satisfies these conditions (two solutions if you consider duplicates).
Number of tests required for $2^5$ wines with 2 poisons = $2*5 + 2*(2*5)$ = 30.
Number of tests required for $2^n$ wines with 2 poisons = $2*n$ + $2*(2*n)$ = $6n$.
1+2=2+1 => 1-1=2-2 and 1^2+2^2=2^2+1^2 => 1^2-1^2=2^2-2^2 => (1+1)(1-1)=(2+2)(2-2) => 2=4
Observe that, we strike off such cases in Part-I. May be I should have said, "Only consider solutions (a,b) where a<b"? Or does this problem completely invalidates my solution?
– blackpen Nov 21 '15 at 14:06