Rat and Poisonous Milk Bottle Puzzle || Google Interview Puzzle


Puzzle Details 

You have 4 bottles of milk. One of them is poisonous while the other 3 are non-poisonous. There is a rat that dies exactly after 10 hours of drinking the poisoned bottle. You have a clock that measures time only in hours. Suggest an optimal strategy to identify the poisoned bottle within 24 hours.




sometimes it can be asked to find the minimum time required to find the poisoned bottle. This is a simple puzzle, now I will explain the logic of finding the poisoned bottle in minimum time.
label all the bottles from 1 to 4.

At the beginning of the first hour feed the rat the Ist bottle. At the start of the 2nd-hour feed, the 2nd one, and similarly at the start of the 3rd-hour feed, the 3rd bottle.
remember there is no need to feed the fourth bottle at the start of 4th hour because if the rat does not die after feeding 3 bottles then obviously the poisoned bottle will be 4.

If the rat dies after exactly 10 hrs, the first bottle is poisonous because this is the first bottle that is fed to the rat and as per the problem statement rat will die exactly after 10 hours of drinking the poisoned bottle hence If the rat dies after exactly 10 hrs then the poisoned bottle is 1st bottle

If the rat dies after 11 hours, 2nd bottle contains poison because 2nd bottle was fed to the rat at the start of the 2nd hour, 1 + 10 is 11 hence if the rat dies after 11 hours 2nd bottle is poisonous.

If the rat dies after 12 hours, 3rd bottle contains poison because 3rd bottle was fed to the rat at the start of 3rd hours, 2 + 10 is 12 hence if the rat dies after 12 hours 3rd bottle is poisonous, and if the rat doesn't die even after 12 hours, definitely the fourth one is poisonous and you don't have to wait till 13th hour to find out whether it's true or not.

Thus after exactly 12 hours, you would be able to determine the poisonous bottle.





You may like these posts:

No comments:

Post a Comment