How 10 Mice Can Pinpoint a Poisoned Bottle Among 1000 Using Binary Logic
This article explains a classic interview puzzle where ten mice and a two‑hour observation window are used to identify a single toxic bottle out of a thousand by encoding the bottles in binary and interpreting the mice's survival as binary bits.
Puzzle Description
We have 10 mice and 1000 bottles of liquid, exactly one of which is poisonous. If a mouse drinks poison, it dies after two hours. With only a two‑hour window, we need a strategy to determine the toxic bottle.
Initial Thoughts
At first the problem seems impossible because each mouse would have to taste many bottles, making it unclear which bottle caused death.
Key Insight: Binary Representation
The hint "How can 10 represent 1000?" points to using binary. Number the mice 0‑9 and treat each mouse’s alive/dead state as a binary digit (0 = alive, 1 = dead). Ten binary digits can represent 2¹⁰ = 1024 possibilities, enough for 1000 bottles.
Number the bottles from 0 to 999 and write each number in a 10‑bit binary form. For each bit position, the corresponding mouse drinks all bottles whose binary representation has a 1 in that position.
After two hours, observe which mice have died. The pattern of dead (1) and alive (0) mice forms the binary representation of the poisonous bottle’s index.
Example: If mice 0, 1, 3, and 5 die, the binary number is 00101011, which equals 2^0 + 2^1 + 2^3 + 2^5 = 1 + 2 + 8 + 32 = 43. Thus bottle 43 is toxic.
Why It Works
Each bottle’s unique binary code determines exactly which subset of mice taste it. Only the poisonous bottle causes deaths, so the resulting death pattern uniquely identifies that bottle.
Broader Applications of Binary
The same binary‑bit idea appears in many systems. For instance, Java’s ReentrantReadWriteLock uses a 32‑bit integer where the high 16 bits track read‑lock state and the low 16 bits track write‑lock state.
Understanding binary representation is fundamental for bit‑mask techniques, memory‑efficient algorithms, and low‑level system design.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
