Mouse drinking problem (the magic of binary encoding)

Source: Internet
Author: User
A total of 1000 bottles of wine were consumed by rats, one of which was toxic. If a mouse drinks toxic wine, it will die one day later. If you are given a day, how many mice do you need to determine which bottle of wine is poisonous? The answer is 10. This requires binary encoding. 1000 bottles of wine require at least 10 digits of binary code. Then, take the ten cups, which represent the ten digits of the binary code respectively, and pour the 1000 bottles of wine into the corresponding cup encoded as 1. Take the ten mice to drink the wine from the ten cups respectively. After one day, you can determine the code of the toxic bottle of wine based on the mouse that drank the cup to die, so as to determine which bottle of wine is toxic. It is based on the location of the poison mouse cup corresponding to the toxic wine encoding. This topic uses some features of binary encoding. Some other questions also use these features. For example, when using special bitwise operations, more bitwise operations are commonly used, that is, and, or, or. In this way, we can correspond to some problems in real life. For example, we originally wanted to solve a similar problem by using more than 900 servers, after such analysis, we can use 10 servers to solve the problem, greatly saving the cost.

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.