[General Puzzles] King and Poisoned Wine

368 views
Skip to first unread message

Ankit Aggarwal

unread,
Apr 1, 2011, 1:43:09 AM4/1/11
to programmi...@googlegroups.com
Lets move on to a bit typical Puzzle. Its pretty common in interviews, so if you know the answer already don't leak it out. Let others try first.

Puzzle 2:
A Bad king has a cellar of 1000 bottles of delightful and very expensive wine. a neighboring queen plots to kill the bad king and sends a servant to poison the wine. (un)fortunately the bad king's guards catch the servant after he has only poisoned one bottle. alas, the guards don't know which bottle but know that the poison is so strong that even if diluted 1,000,000 times it would still kill the king. furthermore, it takes one month to have an effect. the bad king decides he will get some of the prisoners in his vast dungeons to drink the wine. being a clever bad king he knows he needs to murder no more than 10 prisoners - believing he can fob off such a low death rate - and will still be able to drink the rest of the wine at his anniversary party in 5 weeks time.

Best.
--
Ankit Aggarwal

GARV MODWEL

unread,
Apr 1, 2011, 1:56:09 AM4/1/11
to programmi...@googlegroups.com, Ankit Aggarwal




Label the wine bottles from 1 to 1000. Convert the labels into binary system> Thus, we'd get 10bit binary codes for all the wine bottles (since 2^10 is 1024).

Take ten glasses and number them from 1 to 10. Now, Considering wine bottles 63 for instance. Its binary code would be 0000111111. So pour it into glasses 1,2,3,4,5 and 6 (i.e. where ever you get 1 in digits place in the binary code).

Do this for all the bottles. and make those 10 prisoners drink wines in these 10 glasses.

Based on how many prisoner die you'll be able to get 1s in the binary code. For instance, prisoner 1,4,6,9 and 10 die and rest remain alive. Thus, we can conclude that the poisoned bottle binary code would be 1100101001. Reconvert the binary code to decimal form. You'll get the answer.



--
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

unread,
Apr 1, 2011, 2:01:10 AM4/1/11
to programmi...@googlegroups.com
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.


On Fri, Apr 1, 2011 at 11:13 AM, Ankit Aggarwal <anki...@gmail.com> wrote:
--
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
Reply all
Reply to author
Forward
0 new messages