Menu

Earn Premium with Referrals

Invite your friends and earn Premium rewards through our referral program.

See how it works and start inviting friends.

1000 Bottles of Wine
INTERVIEWPUZZLE

1000 Bottles of Wine

Learn how binary representation and carefully designed tests can identify a poisoned bottle using a limited number of testers.

The 1000 Bottles of Wine

The Puzzle: A king has 1000 bottles of wine. One is poisoned. A single drop of this poison will kill a rat after exactly 24 hours. You have 10 rats and only 24 hours to find the poisoned bottle. How do you do it?

1. The Power of 2

2{10}=10242^\{10\} = 1024. This means 10 bits can represent any number from 0 to 1023.

2. The Solution: Binary Mapping

  1. Label each bottle from 1 to 1000 in binary form (e.g., Bottle #1 is 0000000001, Bottle #1000 is 1111101000).
  2. Assign each rat to a specific “bit position” (Rat 1 is bit 1, Rat 2 is bit 2, etc.).
  3. Feed the rats: Rat ii drinks a drop from every bottle that has a ‘1’ in its ii-th bit.
  4. Wait 24 hours.

3. The Result

If Rat 1 and Rat 3 die, but all others live, the binary code of the poisoned bottle is 0000000101 (which is Bottle #5). The set of dead rats gives you the exact binary address of the poisoned bottle.


Interview-Focused Questions

Q: Why don’t we use 1000 rats (one for each bottle)?

A: Because that is inefficient. The question is “How few rats can you use?”. By using binary representation, each rat’s life becomes a bit (Dead=1, Alive=0), allowing 10 rats to represent 2{10}2^\{10\} different states.

Q: What if you had 48 hours instead?

A: If you have more time, you can use fewer rats by using a Ternary (Base-3) or higher system. With two rounds of 24 hours, each rat can have 3 states (Die in round 1, Die in round 2, Live). 7 rats would be enough (37=21873^7 = 2187).

Key Takeaway

This is a classic “Information Theory” problem. It tests if you can think of individuals (rats) as data storage units (bits).

My Private Notes

Notes are auto-saved locally to this device.