12 questions-Microsoft interview questions

Source: Internet
Author: User

There are currently 12 balls, one of which is defective, but I don't know whether it is heavier or lighter than the normal one. Now there is only one frame of the balance. Please name it three times to find the defective ball.

 

Reference 1:

First, divide the 12 small balls into three equal parts, each containing four.
Take out two of them and place them on both sides of the balance (for the first time)
Case 1: the balance is balanced.
Then the eight balls that are named as "Go Up" are normal, especially in four.
Put three of the remaining four balls on one side and three normal balls on the other side (the second time)
For example, the balance between the balances, especially the remaining one.
If the balance is not balanced, in the three above the balance. And know whether it is heavy or light.
Two of the remaining three are called, because we already know the importance, so we can know the special. (Third time)
Case 2: Balance skew.
The special ball is in the eight of the balances.
Mark the four balls on the heavy side as a1a2a3a4 and b1b2b3b4.
The rest is indeed set to four normal records as C.
Put a1b2b3b4 aside, and B1 and three normal c balls aside. (Second)
Case 1: balance the balance.
The special ball is in a2a3a4, and the special ball is heavy.
After you name a2a3, you will know which of the three is special. (Third time)
Case 2: the balance is still A1.
The special ball is between A1 and B1.
Let's take a simple and normal name to know which one is special. (Third time)
Case 3: the balance is reversed, and B1 is heavy.
The special ball is in the middle of b2b3b4, And it is relatively light.
Call B2B3 to know which one is special. (Third time)

 

Reference 2:

This term is called three times to ensure that it finds the Bad ball and knows whether it is heavier or lighter than the standard ball.
Number 12 balls as 1-12.
For the first time, place 1-4 on the left and 5-8 on the right.
1. If the right weight is heavy, the bad ball is on the first day.
Remove 2-4 for the second time, move 6-8 from the right to the left, and put 9-11 for the second time.
On the right. That is to say, place, on the left, 10, and 11 on the right.
1. If the right weight is heavy, the bad ball will not be touched on. If it is number 1,
Then it is lighter than the standard ball; if it is the fifth, it is heavier than the standard ball.
For the third time, place "1" on the left and "2" on the right.
1. If the right weight is used, the first part is a bad ball and lighter than the standard ball;
2. If the balance is reached, the fifth is a bad ball and heavier than the standard ball;
3. This time it is impossible to have a left weight.
2. If the balance is reached, the bad ball is 2-4 away and lighter than the standard ball.
For the third time, place '2' on the left and '3' on the right.
1. If the right weight is used, the second is a bad ball and lighter than the standard ball;
2. If balanced, the 4th is a bad ball and lighter than the standard ball;
3. If the left weight is used, the third is a bad ball and lighter than the standard ball.
3. If the left weight is greater than the standard weight, the bad ball gets 6-8 on the left.
For the third time, place '6' on the left and '7' on the right.
1. If the right weight is greater than the standard weight, the 7 th is a bad ball;
2. If the balance is reached, the 8th is a bad ball and heavier than the standard ball;
3. If the left weight is greater than the standard weight, the 6th is a bad ball.
2. If the balance is reached, the bad ball is on the 9-12 th.
For the second time, place 1-3 on the left and 9-11 on the right.
1. If the right weight is used, the bad ball is 9-11 and the Bad ball is heavy.
For the third time, place '9' on the left and '10' on the right.
1. If the right weight is greater than the standard weight, the 10 th is a bad ball;
2. If the balance is reached, the 11th is a bad ball and heavier than the standard ball;
3. If the left weight is greater than the standard weight, the 9 th is a bad ball.
2. If the balance is reached, the bad ball is the 12th.
For the third time, place 1 on the left and 12 on the right.
1. If the right weight is greater than the standard weight, the 12th is a bad ball;
2. This cannot be balanced;
3. If the left weight is used, the 12th is a bad ball and lighter than the standard ball.
3. If the weight is left, the bad ball is 9-11 and the Bad ball is lighter.
For the third time, place '9' on the left and '10' on the right.
1. If the right weight is used, the 9 th is a bad ball and lighter than the standard ball;
2. If balanced, the 11th is a bad ball and lighter than the standard ball;
3. If the left weight is used, the 10 th is a bad ball and lighter than the standard ball.
3. If the left weight is heavy, the bad ball is in the range of 1-8.
Remove 2-4 for the second time, move 6-8 from the right to the left, and put 9-11 for the second time.
On the right. That is to say, place, on the left, 10, and 11 on the right.
1. If the right weight is heavy, the bad ball gets the 6-8 on the left and is lighter than the standard ball.
For the third time, place '6' on the left and '7' on the right.
1. If the right weight is used, the 6th is a bad ball and lighter than the standard ball;
2. If the balance is reached, the 8th is a bad ball and lighter than the standard ball;
3. If the left weight is used, the 7 is a bad ball and lighter than the standard ball.
2. If the balance is reached, the bad ball is 2-4 after it is removed and is heavier than the standard ball.
For the third time, place '2' on the left and '3' on the right.
1. If the right weight is greater than the standard weight, the third is a bad ball;
2. If the balance is reached, the 4th is a bad ball and heavier than the standard ball;
3. If the left weight is greater than the standard weight, the 2 is a bad ball.
3. If the left weight is heavy, the bad ball will not be touched on. If it is number 1,
Then it is heavier than the standard ball; if it is the fifth, it is lighter than the standard ball.
For the third time, place "1" on the left and "2" on the right.
1. the right weight is not allowed this time.
2. If balanced, the fifth is a bad ball and lighter than the standard ball;
3. If the left weight is greater than the standard weight, the first is a bad ball;

Reference 3:

| -- Right -- (1 light)
| -- Right -- (1; 2) | -- ping -- (5)
| -- Left --()
|
| -- Right -- (2 light)
| -- Right -- (-8; | -- ping -- (2; 3) | -- ping -- (4 light)
| 5, 9-11) | -- left -- (3 light)
|
| -- Right -- (7)
| -- Left -- (6; 7) | -- ping -- (8)
| -- Left -- (6)
|
| -- Right -- (10)
| -- Right -- (9; 10) | -- ping -- (11)
| -- Left -- (9)
|
| -- Right -- (12)
(1-4; 5-8) | -- ping -- (1-3; | -- ping -- (1; 12) | -- ping -- (13 light, 13 heavy )*
| 9-11) | -- left -- (12 light)
|
| -- Right -- (9 Light)
| -- Left -- (9; 10) | -- ping -- (11 light)
| -- Left -- (10 light)
|
| -- Right -- (6 light)
| -- Right -- (6; 7) | -- ping -- (8 light)
| -- Left -- (7 light)
|
| -- Right -- (3)
| -- Left -- (-8; | -- ping -- (2; 3) | -- ping -- (4)
5, 9-11) | -- left -- (2)
|
| -- Right --()
| -- Left -- (1; 2) | -- flat -- (5 light)
| -- Left -- (1)
(*: 13 balls .)

Reference 4:
Divide the ball into three groups and four groups.
First time: Any four to any four
Result: balance. Status quo: 8 standard balls and 4 unknown balls.
Second: 3 unknown balls for 3 standard balls
Result: The remaining UNKNOWN ball is the problematic ball.
Third time: Saving
Result: unbalanced. Status quo: 3 unknown balls and 9 Standard balls.
Analysis and comparison results:
If the three unknown balls are heavier than the three standard balls, the problematic balls are heavier.
If the three unknown balls are lighter than the three standard balls, the problematic balls are lighter.
Third time: 2 unknown balls, 1 to 1
Result: The problematic ball is the last unknown ball.
Result: unbalanced. Based on the above results, if the problematic ball is heavy (light), an unknown ball with heavy (light) is the problematic ball.
Results: unbalanced. Status quo: 4 light balls, 4 heavy balls, and 4 Standard balls.
Second: Light 2 + heavy 2 pairs of standard balls 3 + weight 1
Result: the status quo is balanced. Nine standard balls are left, and two unknown balls are left. The weight is 1.
Third time: light 1 + weight 1 pair of standard balls 2
Result: The remaining one is the problematic ball.
Result: unbalanced
Analysis and comparison results
If one ball is lighter than two standard balls, the problem ball is lighter than one.
If one ball is lighter and one ball is heavier than two standard balls, the problem ball is heavier than one.
Result: unbalanced
Analysis: if the light weight is 2 + 2 is lighter than the standard ball 3 + the weight is 1, the problem ball is 2 on the left and 1 on the right.
Third time: Same as above
If the weight is 2 + + 2 is greater than the standard ball 3 + the weight is 1, the problem ball is on the left and the problem ball is heavy.
Third time: directly compare the two on the left, one to one, and the problem ball.

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.