You have 4 stones. They are of four distinct colors, and they are also of distinct weights of 1, 2, 3, 4 grams. However, you do not know which weight corresponds to which color. The balance scale you have can only indicate which side is heavier or whether the two sides are balanced, without further details. You may put as many stones as you want on each side of the scale.
What is the least number of weighing trials needed to ensure correct weight labeling for all stones?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Can you figure out how to do it in 4 weighings? If not, read Worranat's solution!
Hold on. The problem said it only shows equal or unequal. It didn't say it would show which is heavier
Log in to reply
It's true that the problem can be read in that way (which would then be unsolvable); it's an unfortunate phrasing of the problem. You can report it.
Well the question is quite incorrect if you take into account the probability. That is, if during testing Taking a b c and d Right on Step 1) you obtained the 5=5 equilibrium of 2+3=1+4 or 1+4=2+3, a+d=b+c this is the only two weights = two weights case Step 2) replacing the weight b with weight a, I.e a+c=d, 1+3=4 or 2+1=3 it would mean b is either 2 or 4, a is 1 or 2 and c is 3 or 1 by comparison. Step 3) replacing c with b which is 2 or 4. Now since d can't be more than 4, a+c=4, ie 1+3 or 3+1. Since already established that a is 1 or 2 from above two possibilities a=1 , so c=3, since d= 4, b=2. Only three weighing trials need to be done. Or I might be wrong :p
Log in to reply
What happens if step 2 doesn't give equality? You're lucky that you stumble on a case that works in 3 weighings, but you need to find the number of weighings necessary for all possible cases.
The problem doesn't say we only have ONE of each colour. Let's say we have more, and two balls of the same colour will weigh the same and vice versa. I actually don't need more than 2 balls of each colour, and 3 weighings are enough.
Start as usual, one of each colour, weigh them 2 vs 2. Let's call colours on lighter side A and B, and those on heavier side C and D. (If balanced, just pick a side.)
Case 1: unbalanced, AB on light side, CD on heavy side. Then A or B is 1 and C or D is 4.
Case 2: balanced, AB on one side and CD on the other. Then one side has 1 and 4, and the other side has 2 and 3, but don't know which is which.
Case 1: Put 2 balls of colour A on left and one ball of colour C on the right (AA vs C). - If left side is heavier, the balls (ABCD) are 2134, 3124 or 3142, so AB vs D will tell which is the case. - If right side is heavier, the balls are 1234, 1243 or 1342. AB vs D will decide. - If balanced, the balls are 2143 or 1324. A vs B will decide.
Case 2: Weigh AA vs BC. - If left side is heavier, the balls are 4123, 4132 or 3214. A vs BD will decide. - If right side is heavier, the balls are 1423, 1432 or 2341. AD vs C will decide. - If balanced, the balls are 2314 or 3241. A vs B will decide.
Log in to reply
The problem does say there are 4 differently colored stones of 4 distinct weights. So it's necessarily one per weight, one per color.
Log in to reply
"You have 4 different colored[sic] stones ...", so you have stones of 4 different colours, however many. Anyway, I was just saying, of course you need 4 weighings if you have just one of each, but with multiple stones of each colour (which is allowed with one way to interpret the question) 3 weighings are enough. But to find the solution I had to use a computer to try different arrangements of stones on the balance scale and see which ones divides the possibilities evenly enough.
Log in to reply
@Tomaž Cedilnik – Okay, that's a possible misinterpretation. I'll change it to "4 stones, all of different colors"; hopefully that's more clear.
Whether or not the original problem needs to be worded more carefully in order to convey the author's intention is a minor question. Either way, you've provided a very interesting variation on the problem and solution.
I know no body is going to read this but yet… - this is the solution.
We shall need 4 weighs and I provide the algorithm in the attached picture.
But first let's prove that it's impossible to do this with less weights.
Every weighing action can have 3 outcomes: left is heavier, right is heavier and left equals right.
There are 4! Options for arranging red, green, yellow and blue.
The number of weighing actions should meet the following:
3
N
>
2
4
Which means N=3 or 4 or 5… etc.
I shall show that N=3 is not enough and then I shall show the algorithm for N=4.
The first weigh can be one of the following:
1. One vs. two
2. One vs. three
3. Two vs. two
Let's consider each of these options:
One vs. two – without losing generality let's compare red vs. green+yellow. Let's count the cases where red euquals green+yellow: 3=1+2, 3=2+1, 4=1+3, 4=3+1. It means that we have 4 equal cases. Let's count the number of cases where red is greater than green+yellow: 4>1+2, 4>2+1. It means that we have 2 greater cases. So we are left with 24-4-2=18 cases on which red is less than green+yellow. We are not left with 2 more weighing actions to distinguish between 18 cases. With only 3 outcomes we can distinguish only between 3^2 cases. But we have 18. So we can't.
One vs. Three – No matter what we take – one is always going to be less than adding up 3. Because even in case the one is 4, the other three are 1+2+3 which is 6 and thus 4<6. So after finishing with such a weighing action – we are left with 2 weighing actions to sort out 24. Impossible.
Two vs. two – without losing generality let's compare red+green vs. yellow+blue splits 24 into 8 cases where red+green is less than yellow+blue, 8 cases where they are equal and 8 cases where red+green is more than yellow+blue. We are left with two weights to split 8 cases. No matter what the next weighting action – we shall be left with 4 cases having the same weighing result. The last weighing action cannot distinguish between these 4 because it's it has only 3 outcomes.
So the conclusion is that we can't distinguish between the 24 cases using only 3 weighing actions.
An algorithm for identifying the values of red, green, yellow and blue in 4 weighing actions is illustrate in the image. The first 3 weighing are described on the 3 left most columns. The fourth column weighing action depends on the result of the first three. On the right we can see the conclusion.
Great solution! I enjoyed reading it :)
It is written very rigorously and makes it clear why 4 is the minimum number of weighings required. You have not only shown that it can be done in 4 weighings, but also that it is impossible in 3 or less weighings.
For completeness, you should also include the case One vs one, but that is easily shown.
Among the 4 stones, designated as A to D , there are 3 ways to separate the group into 2 pairs: A + B & C + D ; A + C & B + D ; A + D & B + C .
From one of these pairings, we know that it will result in equal weighing: 2 + 3 = 1 + 4 .
For generality, suppose A + B = C + D .
We know that the maximum weight rests on either side, and any switch from this equalibrium will result in leveling down towards 4-gram stone: 2 + 1 < 3 + 4 and 1 + 3 < 2 + 4 .
Therefore, if we separate the group into 3 pairings as described for weighing, we will reach one equality and two inequalities. For generality suppose:
A + B = C + D A + C < B + D B + C < A + D
Hence, in this case, D is the maximum mass as it favors higher scale, making C the least in order to make the equality true. (If the last inequality has a sign switched to another side, then B will appear twice on the higher scale instead of D .)
That leaves us with A & B unknown, which we can distinguish with just one more weighing.
As a result, we need at least 4 weighings to know all weights.
As always, to prove that something is a minimum, we not only need to show that 1) It can be achieved, we also need to show that 2) No smaller value can work.
Read Ivan's detailed solution to understand why 2 or 3 weighing trials is not sufficient.
You haven't proven that it's impossible to do it in less than 4 weighings; you only proved that it's possible to do it in 4 weighings.
Log in to reply
Any proof from you then?
Log in to reply
It can be done in 3 steps!
Log in to reply
@Kien Hwa – It can and is possible but not for all cases. To ensure all cases, 4 steps are needed. (Please see below notes for clarification).
It seems that it can be done in 3 steps. Below is one possible way, there are probably many more different ways to do it.
Let's use A,B,C,D for the 4 colors.
Case 1: If A+B=C+D, then use A+A vs C+D
1a: A+B=C+D & 2A=B+C means either ABCD=2314 or ABCD=3241
A+B=C+D & 2A=B+C & A>B means ABCD=3241
A+B=C+D & 2A=B+C & A<B means ABCD=2314
1b: A+B=C+D & 2A>B+C means either ABCD=3214 or 4123 or 4132
A+B=C+D & 2A>B+C & A=2C means ABCD=4123
A+B=C+D & 2A>B+C & A>2C means ABCD=3214
A+B=C+D & 2A>B+C & A<2C means ABCD=4132
1c: A+B=C+D & 2A<B+C means either ABCD=1423 or 1432 or 2341
A+B=C+D & 2A<B+C & B=2D means ABCD=1432
A+B=C+D & 2A<B+C & B>2D means ABCD=2341
A+B=C+D & 2A<B+C & B<2D means ABCD=1423
Case 2: If A+B>C+D, then use 3A vs B+C+3D
2a: A+B>C+D & 3A=B+C+3D means either ABCD=3412 or 4213
A+B>C+D & 3A=B+C+3D & A>B means ABCD=4213
A+B>C+D & 3A=B+C+3D & A<B means ABCD=3421
2b: A+B>C+D & 3A>B+C+3D means either ABCD=4231 or 4321 or 4312
A+B>C+D & 3A>B+C+3D & B+D=2C means ABCD=4321
A+B>C+D & 3A>B+C+3D & B+D>2C means ABCD=4312
A+B>C+D & 3A>B+C+3D & B+D<2C means ABCD=4231
2c: A+B>C+D & 3A<B+C+3D means either ABCD=2413 or 2431 or 3412
A+B>C+D & 3A<B+C+3D & A+C=2D means ABCD=3412
A+B>C+D & 3A<B+C+3D & A+C>2D means ABCD=2431
A+B>C+D & 3A<B+C+3D & A+C<2D means ABCD=2413
Case 3: If A+B<C+D, then use 3D vs B+C+3A
3a: A+B<C+D & 3D=B+C+3A means either ABCD=1243 or 3124
A+B<C+D & 3D=B+C+3A & A>B means ABCD=3124
A+B<C+D & 3D=B+C+3A & A<B means ABCD=1243
3b: A+B<C+D & 3D>B+C+3A means either ABCD=1234 or 1324 or 2134
A+B<C+D & 3D>B+C+3A & A+C=2B means ABCD=1234
A+B<C+D & 3D>B+C+3A & A+C>2B means ABCD=2134
A+B<C+D & 3D>B+C+3A & A+C<2B means ABCD=1324
3c: A+B<C+D & 3D<B+C+3A means either ABCD=1342 or 2143 or 3142
A+B<C+D & 3D<B+C+3A & B+D=2A means ABCD=2143
A+B<C+D & 3D<B+C+3A & B+D>2A means ABCD=3142
A+B<C+D & 3D<B+C+3A & B+D<2A means ABCD=1324
Log in to reply
Yes, but there is only 1 stone of each kind though.
I think there is one scenario where 3 weighings is possible. Here is my reasoning:
Weighing #1: A+B < C+D, which means one of (A,B) must be 1 and the other must be 2 or 3, agree?
Weighing #2: Put A and B on the two sides of the scale. Now, we know which one is 1. Let's assume A is 1 and B is either 2 or 3.
Weighing #3: Put B and C on the two sides of the scale. What if B>C? In this case, B has to be 3 and C has to be 2. That leaves D with only one number - 4. I can't see other possibilities. So now we know the weights of all colored stones.
This of course doesn't work in all cases. But at least in this particular case, 3 weighings seem to suffice. Let me know your thoughts.
Log in to reply
Yes, it is possible that 3 weighings are enough but not for all cases. That is why 4 weighings are needed to ensure all of them.
Usually (and for this problem, it is the case) this kind of questions asks for "the minimum number of weighings such that no matter what happens , you can do the task in at most that number". Three suffices for some cases, but not others, so it's not the answer.
We can start measuring in different combinations of stones putting on the left or right side of the measuring scale. 1. We can put all the four stones in one side and nothing on the other side; this will not give us any information. So we are not going to take our first step like this. 2. Now we can put three stones on one side and the other one on the other side of the scale; this will also not give us any information at all; all possible combination of three stones will always be heavier than the other. So we are not going to take our first step like this. 3. So the only possible combination remains is to select two stones on one side and the other two on the other side of the scale. Step 1: Select any two stones on one side and the remaining two to the other side. Say our stones’ are labeled as A, B, C, and D. In this case we will get eight possible combinations and the three possible cases: {1,2}, {1,3}, {1,4}, {2,3}, {2,4}, {3,4} Case 1: 2+3=1+4 Step 2: comparing the first two stones we can sort out 2 and 3 Step 3: comparing the second two stones we can sort out 1 and 4 Case 2: 3+4>1+2 or 2+4>1+3 For both Case 2 and Case 3 the heavies contains 4 and lighter contains 1 Step 2: Comparing the heavier we can sort out 4 Step 3: comparing the lighter we can sort out 1 Step 4: comparing the remaining two we can easily sort out 2 and 3
Number of equations should be equal to number of unknowns.
We can form equations taking variables as R, G, Y & B.
As there are four variable, at least 4 equations are needed i.e at least 4 trials are needed
To do it in 4 weighing trials is rather easy.
Semifinal 1: R vs G
Semifinal 1: Y vs B
Final (1 vs 2 position): Heavier (R,G) vs Heavier (Y,B)
Final (3 vs 4 position): Lighter (R, G) vs Lighter (Y,B)
But it can be done in 3 weighing trials but the solution is much more elaborate!
Log in to reply
This just gives you the heavier and the lighter stones... But you don't know which of Lighter(Final1) and Heavier(Final2) is which...
It seems that it can be done in 3 steps. Below is one possible way, there are probably many more different ways to do it.
Let's use A,B,C,D for the 4 colors.
Case 1: If A+B=C+D, then use A+A vs C+D
1a: A+B=C+D & 2A=B+C means either ABCD=2314 or ABCD=3241
A+B=C+D & 2A=B+C & A>B means ABCD=3241
A+B=C+D & 2A=B+C & A<B means ABCD=2314
1b: A+B=C+D & 2A>B+C means either ABCD=3214 or 4123 or 4132
A+B=C+D & 2A>B+C & A=2C means ABCD=4123
A+B=C+D & 2A>B+C & A>2C means ABCD=3214
A+B=C+D & 2A>B+C & A<2C means ABCD=4132
1c: A+B=C+D & 2A<B+C means either ABCD=1423 or 1432 or 2341
A+B=C+D & 2A<B+C & B=2D means ABCD=1432
A+B=C+D & 2A<B+C & B>2D means ABCD=2341
A+B=C+D & 2A<B+C & B<2D means ABCD=1423
Case 2: If A+B>C+D, then use 3A vs B+C+3D
2a: A+B>C+D & 3A=B+C+3D means either ABCD=3412 or 4213
A+B>C+D & 3A=B+C+3D & A>B means ABCD=4213
A+B>C+D & 3A=B+C+3D & A<B means ABCD=3421
2b: A+B>C+D & 3A>B+C+3D means either ABCD=4231 or 4321 or 4312
A+B>C+D & 3A>B+C+3D & B+D=2C means ABCD=4321
A+B>C+D & 3A>B+C+3D & B+D>2C means ABCD=4312
A+B>C+D & 3A>B+C+3D & B+D<2C means ABCD=4231
2c: A+B>C+D & 3A<B+C+3D means either ABCD=2413 or 2431 or 3412
A+B>C+D & 3A<B+C+3D & A+C=2D means ABCD=3412
A+B>C+D & 3A<B+C+3D & A+C>2D means ABCD=2431
A+B>C+D & 3A<B+C+3D & A+C<2D means ABCD=2413
Case 3: If A+B<C+D, then use 3D vs B+C+3A
3a: A+B<C+D & 3D=B+C+3A means either ABCD=1243 or 3124
A+B<C+D & 3D=B+C+3A & A>B means ABCD=3124
A+B<C+D & 3D=B+C+3A & A<B means ABCD=1243
3b: A+B<C+D & 3D>B+C+3A means either ABCD=1234 or 1324 or 2134
A+B<C+D & 3D>B+C+3A & A+C=2B means ABCD=1234
A+B<C+D & 3D>B+C+3A & A+C>2B means ABCD=2134
A+B<C+D & 3D>B+C+3A & A+C<2B means ABCD=1324
3c: A+B<C+D & 3D<B+C+3A means either ABCD=1342 or 2143 or 3142
A+B<C+D & 3D<B+C+3A & B+D=2A means ABCD=2143
A+B<C+D & 3D<B+C+3A & B+D>2A means ABCD=3142
A+B<C+D & 3D<B+C+3A & B+D<2A means ABCD=1324
I am not following your solution. How do we actually form these equations?
Log in to reply
What I'm trying to tell is that we can solve without forming equations.
There is a general rule that number of equations should be equal to number of unknowns to find all the unknowns.....So using that here we need 4 equations. But, the question asks us the number of trials. (With each trial we will get a equation) So, we need at least 4 trials
Log in to reply
Unfortunately, that argument doesn't always work.
If we had equations that were linearly independent , then we only need n equations to determine n unknowns. Because each equation determines a R n − 1 plane in R n , the intersection of n planes in general position is a single point which gives us our solution.
Unfortunately, since we might have linear inequalities in this case, as such the bounds are not strong enough. Analogously speaking, each linear inequality only determines half of R n , and it's not clear why the intersection of these n planes will yield a single (lattice) point.
most of them will be inequations...
This is incorrect.
By your logic, if there are 5 stones (instead of 4), then your answer is 5, which can be easily shown to be wrong.
Problem Loading...
Note Loading...
Set Loading...
It's easy to do this in 4 weighings, as shown elsewhere. I'll prove this is the minimum.
Each weighing has three possible results, so each weighing will provide us with at most lo g 3 bits of information. We need to distinguish 4 ! = 2 4 cases, so we need at least lo g 3 lo g 2 4 > 2 weighings, so we need at least 3 weighings...
...is it the lowest bound, though? As it turns out, it isn't.
With 2 weighings, we obtain at most 2 lo g 3 = lo g 9 bits of information, so we can distinguish at most 9 cases. Suppose we only need 3 weighings, and consider the first weighing. Upon a result of "equal", "left heavier", and "right heavier", we're left with a , b , c cases each, with a + b + c = 2 4 . But since we only need 3 weighings, after this first weighing, we only need 2 more weighings to finish; so, a , b , c ≤ 9 (otherwise we have too many cases to distinguish with just 2 weighings). Among the possible first weighings, only one allows us to continue:
Call the stones A, B, C, D, and suppose our first weighing compares A+B versus C+D. Suppose we get a result of equal. Now we don't have any possible second weighing:
This shows that 3 weighings is not enough, thus requiring 4 weighings.