There are 12 balls, a defective product, and a balance. It is called three times to determine which one is a defective product. What is the title?

Source: Internet
Author: User

The last time I went to interview Microsoft intern, the interviewer asked me a question. There are 12 balls, a defective product, and a balance. It is called three times to determine which one is a defective product. What is the title? At that time, I hesitated first. I first asked him: Do you know whether the defective products are light or heavy? He told me not to know. I am so confused. What should I do. I first thought about it and divided 12 balls into three parts. Half thought about it. Unfortunately, I didn't think of the final result, so I had to give up. Although this problem has long existed, I have never heard of it. I will post this answer today. Warn yourself that you must work hard.

Separate the 12 balls and divide them into three groups at will. Without losing its universality, they are:

(1, 2, 3, 4)... ①; (5, 6, 7, 8)... ②; (9, 10, 11, 12)... ③.

First, place group ① and group ② on both ends of the balance. There are two possible results:

One is Ping, and the other is uneven. Assume that group ① Is more important than group ②.

First, let's look at the ping situation. Then all balls from 1 to 8 are normal. Defective items must be in group ③, that is, 9-12.

You can select three from 9-12 (9, 10, 11 )... ④ Save the 12th ball: You can also choose 3 from the regular ball 1 to 8. You may wish to choose (1, 2, 3 )... ⑤.

Perform the second name for ④ and ⑤. There are three results: ④ = ⑤; ④> ⑤; ④ <⑤.

If ④ = ⑤, the second item is ball 12. For the third time, use the 12th ball as the name of any normal ball, you can immediately determine whether the 12th second ball is heavy or light.

If ④> ⑤, the defective ball will be placed in the 3 balls in the group ④, and will be heavier than the normal ball. In this case, you can select two of the three balls (9 and 10) on the 9-11 and put them on the balance for the third time. There are three cases: 9 = 10; 9> 10; 9 <10.

When 9 = 10, the second item must be the 11th ball, which is heavier than the normal ball. When 9> 10, the second ball is the second item. When 9 <10, the highlighted ball 10 is a defective product.

Likewise, we can prove the situation when we <⑤.

Continue to prove the case of another injustice.

When there are two kinds of circumstances, that is, group ①> group ②; group ① <group ②.

Now we will discuss the situation of group ①> group ②. That is, (1, 2, 3, 4) is more important than (5, 6, 7, 8 ).

Adjust the balls in group ① and group ② and regroup them: Leave the ball No. 3 in group ①, take out the ball No. 4, and put the ball No. 1 and 2 in group ②, and add a normal ball. You may wish to set it to ball 9. Leave ball 7 in group ②, take out the ball 6 and 8, and put the ball 5 in group ①, new group: (5, 3, 9 )... ③; (1, 2, 7 )... ④.

Now, the second term is used to place group 3 and Group 4 on the balance. Result 3:

③ = ④; ③> ④; ③ <④.

When ③ = ④. Then the defective ball will be in the several balls taken out, that is, in the 4, 6, and 8, and the 4 ball should be at least one of the 6 and 8 balls. At this time, the third name is called with the No. 6 ball and the No. 8 ball. The result is 6 = 8, 6> 8, and 6 <8. When No. 6 is equal to No. 8, the No. 4 ball is a defective ball, and it is heavier than the normal ball. When No. 6> the 8 ball is a defective ball, it is lighter than the normal ball; when the 6 th is <8, the second item is the 6 th ball, which is lighter than the normal ball.

When ③> ④. Note: after the change, the Group still maintains the essence of the original group. This is caused by the ball that remains unchanged in the group. Then, the defective ball must be between Ball 3 and ball 7, and I know that ball 3 must be more important than ball 7. At this time, the third time said: from the 3 and 7 balls to choose one and the normal ball said, you may wish to choose the 3 ball and the normal ball 9 claim. The result is: No. 3 = 9; No. 3> 9; No. 3 <9. When the 3rd = 9th, the second item is the 7th ball, which is lighter than the normal ball. When the 3rd> 9th, the second item is the 3rd ball, it is heavier than the normal ball. When the number 3 is <9 and the number 3 is later than the number 7, the number 3 and the number 7 are both defective. This is impossible, this is because there is only one conflict with the defective product specified in the condition.

When ③ <④. This is caused by the exchange of groups of balls. Therefore, the second ball must be between 1, 2, and 5, and the fifth ball should be at least one of the first and second balls. In this case, the ball No. 1 and No. 2 are called for the third time ,. The result is: 1 = 2, 1> 2, and 1 <2. When 1st = 2nd, the defective product is 5th, Which is lighter than the normal ball; When 1st> 2nd, the defective product is 1st, Which is heavier than the normal ball; when the first day is less than the second day, and the fifth day is also less than the second day, the second product is the second day, It is heavier than the normal ball.

Likewise, it can be proved: group ① <group ②.

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.