Rat poison Problems

Source: Internet
Author: User

This is a widely spread problem: there are 1000 bottles of liquid, one of which is poison, and the others are clear water. The poison looks like water and can only be tested with rats. The mouse died at any time of the day a week after drinking the poison. How many mice are needed to find the poison?


One of N bottles of liquid is toxic, and N possibilities exist in total, expressed by N. After a mouse test, the life and death can be expressed as 0 and 1. the life and death of R mice are 0 and 1 strings, and there are two results in R sub-square in total, it is represented by the Set R.

We need to find an experiment method F, which maps the elements in N to R respectively. And the two elements in N cannot correspond to the same element in R.

That is to say, 1st bottles of toxic and 2nd bottles of toxic are two possibilities. We cannot get the same life and death for the mouse after we finish the experiment.

Therefore, the elements in R must be equal to at least N. Therefore, the R power of 2 is greater than or equal to N, r> = Log (n ).

Back to this question, in theory, we need 10 mice to find the hidden poison.


Specifically, what should we do? That is, we need to find an algorithm. And can this algorithm only use 10 mice to find the poison in the 1000 formula?

If there is a mouse, we can make it drink half of the potion. Its Life and Death determine the half of the poison.

For example, n = 8.

000 001 010 011 100 101 110 111

Mouse A 1 1 1 1

The potion of Mouse A and the right side. If the poison is on the right half side, the mouse will die. Otherwise, the mouse will survive.

That is to say, using binary to encode the potion, the life and death of a mouse can indicate the situation of this bottle of poison.

000 001 010 011 100 101 110 111

Mouse A 1 1 1 1

B 1 1 1 1

C 1 1 1 1


If it is a 1000-bottle potion, It is represented in binary. According to the above method, we can use 10 mice to find the only poison.


There are still some changes to this problem.

If there are two bottles of poison in 1000 bottles of liquid, what should we do if we need at least one mouse?

Based on the preceding method, we first calculate the lower bound in theory.

The total distribution of viruses is C (, 2). We need at least 19 mice.


How can this problem be solved?

First, divide the poison into two groups. How can we determine the group of the poison?

For example:

A: 000 001 010 011

B: 100 101 110 111

A mouse is not enough.

We use two mice, A and B. A drinks group A and B drinks group B.

If both mice die, we can determine that the poison is in A and B respectively. If only one mouse dies, we can determine that two bottles of poison are in the same group.

That is to say, through the appeal method, we can determine the status of the 1st bits represented by the binary number of the poison number (both 1 and 0, respectively, 0 and 1)


Can this Method determine the status of 2nd bits?

The answer is yes.

But there is a problem.

If 1st bits are 0, 1, and 2nd bits are also 0 and 1, are the numbers of the two bottles 00, 11, 01, and 10?


How can this problem be solved?

If we know that the 1st bits of the two bottles of poison are different

For example:

A: 000 001 010 011

B: 100 101 110 111

Poison 1 is in group A and poison 2 is in group B, so this problem becomes a problem of finding a bottle of poison. For n = 8, we can use two more pairs of mice to find the number of two bottles of poison.

If we have the opportunity to perform a two-week test, we can use 2 pairs of mice in the first week (why 2 pairs ?) Find out which part of the poison number is different. After knowing which one is different, use two pairs of mice in the next week to get the other values of two bottles of poison. In other words, we can use 2 * log2 (n/2) + 2 * log (n/2) to find two bottles of poison in two rounds of experiments.


But we only allow one round of test time. How can we solve this problem?

Since we can't guess, we're all done.

For n = 8, the number of the two bottles of poison may be 1, 2, or 3. There is always a difference, and there may be several different.

We place 1st Different bottles of poison in group A and group B:

A: 000 001 010 011

B: 100 101 110 111

Use two pairs of mice to test group A and group B respectively.


The additional 2nd bits are different. The two bottles of poison are respectively in group C and group D:

C: 000 001 100 101

D: 010 011 110 111

It also uses two pairs of mice.


Different groups E and F are placed on another 3rd bits:

E: 000 010 100 110

F: 001 011 101 111


So what will the test result be like?

Assume that the two bottles of poison are numbered at 3rd bits.

For example, if it is 010,100, the test results of Group E and group F are that all the mice in group F survive;

If it is 011,111, then the test results of Group E and group F are that all rats in group E are alive.

Therefore, the assumption that the 3rd bits are different is not true.

That is to say, if one of them is the same, all the experiments for that one will be active in one group. Therefore, the two groups of experiments for this role are invalid.


If the two bottles of poison are different in 1st bits,

For example, if the poison numbers are 011 and 100, then all groups A and B will die, then the assumption that the 1st bits are true is that we can get the values of each bits.


To sum up, we need 2 * log (n/2) mice to guess that a certain location is different. To hold all the digits, we need log (n) * 2 * log (n/2): A mouse.

That is to say, if n = 1000, there are two bottles of poison. In the above method, we need (10*2*9) 180 mice to find the poison number.

It is a little far from our bottom 19.



Rat poison Problems

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.