Each of 1000 bottles can be number from 1 to 1000. Each number can be represented by a binary 10 bit number (2 power 10 = 1024) .
Mark each of persons from 1 to 10 .
For bottles 1 to 1000:
Step 1: Take note of the bottle number
Step 2: In binary format check which bits are set to 1 and make those particular numbered persons drink that bottle
Ex: 5 = 00 0000 0101
So person numbered 1 and 3 will drink the bottle .
After the above 2 steps are performed for every bottle . Some prisoners will die . Depending on which prisoners who are dead set those bits and convert that number to decimal.
Example: Say number 3 and number 4 prisoners are dead . Bits : 00 0000 1100 which is 12 in decimal . So the bottle numbered 12 is the poisoned bottle.
--
Visit http://www.gowrikumar.com for good puzzles in C programming language and programming interview questions.
You received this message because you are subscribed to the Google Groups "Programming Puzzles" group. To post to this group, send email to programmi...@googlegroups.com
--
Kusum Kumar Madarasu
IVth Year Information Systems
BITS Pilani Goa Campus