跪拜 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
Featured comments
辞去归来兮

I don't get it. One mouse is clearly enough. Just let 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 just eliminate that one. It's a bit like asking a PhD whether rain falling from ten thousand meters would kill someone. A bunch of PhDs are busy calculating, but they're outdone by a cleaning lady asking, "Haven't you ever been rained on?"

辞去归来兮

Don't ask me if the efficiency would be terrible, because I feel sorry for the mouse [innocent-dumb]

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

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

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