1
$\begingroup$

The question is as follows:

A scientist creates a new compound, called compound A, that will explode 10 days after being mixed with compound B. This compound A was stored in a label-less bottle on a shelf with $n-1$ bottles of non-reactive material, and the scientist doesn't know which is compound A. There is exactly one bottle of compound A among the $n$ bottles on the shelf. The scientist has $O(log(n))$ beakers full of compound B. How can he determine which of the $n$ bottles is the compound A in exactly 10 days time?

I am a little stuck because I don't know how to narrow down the specific bottle in only 10 days. It is pretty obvious that you can just apply the first half of the bottles to the first beaker, and then if it doesn't react you know that the desired bottle is in the second half and so forth. But how do I narrow it down without witnessing the results of the first few tests?

We need to create something where a series of explosions will help us narrow down which one it is (lets say at first its amongst n/4, then n/10, then n/100, etc). How the heck do I do this?

$\endgroup$
2
  • 4
    $\begingroup$ Please credit the original source of all copied material. $\endgroup$
    – D.W.
    Jan 17, 2020 at 0:54
  • $\begingroup$ I apologize. I cannot provide a source because theres no online link or anything for this problem. $\endgroup$
    – KyleCraig
    Jan 18, 2020 at 4:25

1 Answer 1

2
$\begingroup$

This is a classical problem that I have previously seen framed as a puzzle rather than a CS question (with some fixed $n$ and fixed number of beakers), though I don't remember any source for it.

You can solve it as follows: Number your bottles from $0$ to $n-1$, and label your beakers from $1$ to $\lfloor\log_2(n-1)\rfloor+1$ (the number of bits needed to represent numbers $0$ to $n-1$ in binary).

Now for every bottle, do the following: let $x$ be the label of the bottle. For every $i$ such that there is an $1$ at the $i$'th position in the binary representation of $x$, put a bit of that bottle's compound in beaker $i$.

Now after 10 days, the beakers which explode will exactly spell out the number of the explosive bottle in binary.

$\endgroup$
1
  • $\begingroup$ Thanks a lot that makes sense. Can you suggest any resources for getting better at solving these sorts of puzzles? $\endgroup$
    – KyleCraig
    Jan 18, 2020 at 4:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.