跪拜 Guibai
← All articles
Interview · Algorithm · Programmer

10 Mice, 1000 Bottles, and the Binary Trick That Exposes CRUD-Only Backend Engineers

By Fox爱分享 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

The question is a fast proxy for whether a backend candidate internalizes bitwise reasoning and space-time tradeoffs. Engineers who can't map a set of binary states onto a lookup problem will struggle with bitmaps, Bloom filters, and the kind of compact data structures that keep high-scale systems from falling over.

Summary

The classic puzzle — one poisoned bottle hidden among 1,000, with mice that die exactly one hour after drinking — has a precise answer: 10 mice. Each bottle gets a 10-bit binary label. A mouse drinks from a pool containing a drop of every bottle whose nth bit is 1. After the poison takes effect, the pattern of dead mice reads out as the binary index of the poisoned bottle. 2^10 = 1024 states, which covers all 1,000 bottles with room to spare.

ByteDance and other large Chinese tech firms use this question to filter for engineers who understand information density, not just procedural logic. The setup mirrors a bitmap or Bloom filter: a tiny bit array encodes membership across a large set. Ten bits resolve 1,000 possibilities in one parallel round, trading a small amount of space for zero additional time.

The trap answer is 20 or some linear-search count. The right answer signals that the candidate thinks in state-space compression and bitwise operations — the same instincts that separate engineers who build high-throughput systems from those who only write CRUD wrappers.

Takeaways
Ten mice can uniquely identify one poisoned bottle among 1,000 because 2^10 = 1024, which exceeds the bottle count.
Assign each bottle a 10-bit binary number; for each bit position, collect a drop from every bottle with a 1 in that position into a separate test pool.
Let mouse n drink from pool n; after the poison's incubation period, the binary number formed by dead mice (1) and live mice (0) is the exact bottle number.
The method is a single-round parallel test — no sequential retries needed.
ByteDance interviewers use this to probe understanding of bitmaps, Bloom filters, and state-space compression rather than pure logic puzzles.
Conclusions

The question functions as a quick classifier: a candidate who defaults to linear search reveals they don't reach for binary encoding as a first instinct, which is a red flag for roles that involve high-throughput data structures.

Many experienced backend engineers who live in high-level frameworks lose fluency with bitwise operations; this puzzle exposes that gap in minutes.

The setup is isomorphic to a Bloom filter with no false positives — each bottle maps to a unique bit pattern, so the 'filter' is actually a perfect hash.

Concepts & terms
Binary encoding for set membership
Representing each item in a set by a unique binary number so that a small array of bits (or mice) can test for membership in parallel. With N bits, up to 2^N items can be distinguished.
Bitmap / Bloom filter intuition
A bitmap uses one bit per possible key; a Bloom filter uses multiple hash functions to set bits, trading a small false-positive rate for extreme space efficiency. The mouse puzzle is a perfect, collision-free bitmap.
Space-time tradeoff in testing
Using 10 mice tests all 1,000 bottles simultaneously (space cost: 10 mice; time cost: one incubation period). Using 1 mouse sequentially would take up to 1,000 incubation periods — a classic tradeoff.
From the discussion

The core dispute is whether the binary-encoding solution is over-engineered. A loud faction insists one mouse drinking sequentially solves the problem with zero casualties beyond the unlucky tester, dismissing the 10-mouse method as academic navel-gazing. The counterpoint, implied in replies, is that the one-mouse approach ignores implicit constraints like time or a limited number of test rounds, without which the puzzle collapses into triviality. A secondary thread questions the physical assumptions: whether a sip constitutes a lethal dose and whether alcohol poisoning from multiple non-toxic samples would confound the result.

A single mouse drinking bottle by bottle until it dies identifies the poison without any binary encoding, making the 10-mouse solution needlessly complex.
The one-mouse sequential method only holds if there are no time or attempt limits; the binary solution's value emerges precisely from such unstated constraints.
Binary encoding of 1,000 bottles (2^10 = 1,024) is just a binary search in disguise, not a novel trick.
The puzzle's physical premise is shaky—a micro-sample may not deliver a lethal dose, and cumulative alcohol from multiple non-toxic samples could kill a mouse before the poison does.
The article's framing as a real interview anecdote is called out as fabricated, a style imported from Zhihu sob-story content.
Featured comments
辞去归来兮 5 likes hot

Don't get it. One mouse is clearly enough. Just have one mouse keep testing the poison. It'll die when it drinks the poisoned one. There's only one poisoned bottle, so once it hits it, you've eliminated it. Kind of like asking a PhD student whether rain falling from 10,000 meters would kill someone? A bunch of PhDs doing all sorts of calculations, but they're no match for a cleaning lady asking: 'Haven't you ever been caught in the rain?'

辞去归来兮

Don't ask me if the efficiency would be super low, because I feel sorry for the mouse [innocent dumbfounded]

你说是那就是  → 辞去归来兮

Haha, this kind of problem should also have time and attempt limits, otherwise the question is meaningless.

王珩280 8 likes hot

Without any other constraints, I think one mouse is enough. Just let this mouse drink. If it doesn't die, switch to the next bottle. If it dies, you've found the poisoned wine. [grin]

hinotoyk

hahahahahahahahahahahahahahahahahahahahahaha

林魉魉 1 likes

2^10=1024. Isn't the algorithm just a simple binary search? Why make it so convoluted?

See top comments, translated →
Source: juejin.cn ↗ Google Translate ↗ Backup ↗