Beam Balance Strikes Back

You have 6 coins of distinct weights and a beam balance with two pans. You devise an algorithm that identifies the second lightest coin with complete certainty with at most M M weighings.

What is the minimum possible value of M ? M?


Consider trying this problem first.

5 6 7 8 9

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.

4 solutions

Stephen Brown
Nov 20, 2017

Consider coins A, B, C, D, E, F. Knowing which coin is second-lightest inherently requires that you know which coin is the lightest (this isn't immediately obvious but easy to convince yourself). As shown in the sample problem, this requires at least five moves: make three comparisons and form winners and losers piles, let's say A>B, C>D, E>F, then make two comparisons within the losers pile, let's say B>F and D>F, showing F is the lightest. Then the second-lightest must be one of B, D, or E; two more comparisons will reveal the answer.

This is also the method I ended up using.

Chase Hamilton - 3 years, 6 months ago

I'm willing to accept the idea that it's mostly clear you need to know the lightest to know the second lightest. (Proving this seems interesting!)

That said, it isn't clear that the specific algorithm you mentioned to find the lightest is the best one to use as a basis for finding the second lightest. I.e., how do we know that there is not another 5-step algorithm to the lightest that only takes 1 more step to find the second lightest?

Eli Ross Staff - 3 years, 6 months ago

Log in to reply

How indeed. I'm looking forward to an actual proof myself, as these problems aren't my specialty, but I didn't want to see the problem without any solution I guess. The idea is that you need enough measurements to form the four relations (assuming E is second-lighest, F is lightest): A>E>F, B>E>F, C>E>F, and D>E>F.

Stephen Brown - 3 years, 6 months ago

Proving that you'll also know the lightest is easy. Suppose coin A is the second-lightest, and we don't know the lightest coin: it has two (or more) possibilities, B and C.

First, observe that no matter what the lightest coin is, we must have compared A with it. Otherwise, we can flip A and it in the position, and we can't tell the difference, but now A is the lightest coin, contradiction. Thus we must have compared A with at least one of B and C. WLOG we have compared A with B. Now, if B is heavier than A, then B can't be the lightest coin. And if B is lighter than A, then B must be the lightest coin (since we assumed A is the second-lightest), which means C can't be the lightest. Either way we get a contradiction: we assumed B and C are both possibly the lightest, but as it turns out, one of them can't be the lightest.

Note that the generalization to third-lightest and more is different. You'll know which coins are lighter than A and which are heavier, but not necessarily the order among them. The reason this gives the lightest coin if we assume A is the second-lightest is because there is only one lighter coin than A. If A is the third-lightest (and thus there are two lighter coins than A), we can't tell which of the two is actually the lightest.

Ivan Koswara - 3 years, 6 months ago

Well if we have already obtained that B>D then the debate for the second lightest is between D & E which would require 1 comparison . That gives the answer to be 6

Aniket Ani - 3 years, 6 months ago

Log in to reply

Right you are; I'll edit to reflect worst-case scenario.

Stephen Brown - 3 years, 6 months ago

Minimal values of M (or, at least, the minimal values I've come up with), depending on the total number of coins:

1:0

2:1

3:3

4:4

5:6

6:7

Does this pattern continue?

Peter Byers - 3 years, 6 months ago

Log in to reply

What pattern? 3 ( n 1 ) 2 \left\lfloor \frac{3(n-1)}{2} \right\rfloor ? Definitely not; the correct number is n + log 2 n 2 n + \lceil \log_2 n \rceil - 2 (except for n = 1 n = 1 , in which there is no second-lightest).

(By the way, I haven't actually managed to prove that this is the smallest possible. But it's definitely achievable, and it looks like it should be smallest. So take it as a conjecture.)

Ivan Koswara - 3 years, 6 months ago

I don't understand why M=6 is not the good answer : if I start as for the sample problem, I can know the 3 lightest coins (we can suppose A,B and C without loss of generality) with 3 weighings. Then I can compare all pairs (A&B, A&C and B&C) with 3 other weighings, wich allow me to know the order of the 3 lightest coins, and in particular the second lightest coin. Then M=3+3=6. Where is the mistake? Thank you in advance!

Cédric lastname - 3 years, 6 months ago

Log in to reply

How do you know the 3 lightest coins after 3 weighings?

Stephen Brown - 3 years, 6 months ago

If you try to compare A<D, B<E, C<F, it's possible that the actual order from lightest to heaviest is A, D, B, E, C, F. Your three coins A, B, C are not the lightest three.

Ivan Koswara - 3 years, 6 months ago

The smart-alec’s solution: you can do it in five taking note of the discrepancies in weighings. Fix A and weigh the other five against it, then observe how much each is displaced and you have the exact order of lightness.

Lee Wall - 3 years, 6 months ago

I am not totally convince with your algorithim. Let us take as values wheight A=2 and B =1; C=5 and D=4; E=6 and F =3 Following your algorithim you discard A the second lightest up front.In my opinion you need 9 test like a sorting procedure.

Mara Jares - 3 years, 6 months ago

Log in to reply

In this case, we'd get A>B, C>D, E>F, then D>B, F>B, telling us B is the lightest. Then we know the second-lightest must be one of A, D, or F. We test and get D>A and F>A, so A is second-lightest.

Stephen Brown - 3 years, 6 months ago

nice solutions. i am disappointed. i thought in the correct direction and then changed. thanks for the nice solutions.

Srikanth Tupurani - 3 years, 2 months ago
Mark Hennings
Nov 20, 2017

Let the six coins be A , B , C , D , E , F A,B,C,D,E,F , and start by weighing A v D A\,v\,D , B v E B\,v\,E and C v F C\,v\,F . Suppose that A < D A < D , B < E B < E and C < F C < F . The second lightest coin is either the middle coin of A , B , C A,B,C or else the coin originally weighed against the lightest coin of A , B , C A,B,C (in other words, if A < B < C A < B < C , the second lightest coin could be D D ). We can determine the order of A , B , C A,B,C in three weighings - suppose that A < B < C A < B < C . One more weighing of B v D B \,v\,D tells us whether B B or D D is the second lightest coin. We can determine the second lightest coin in 7 \boxed{7} weighings.

Since we do not know the weights of the various coins, there is no advantage to be gained by comparing the weights of groups of coins, so we must always simply compare one coin with another. For any algorithm, let us see where we have got to after the first three weighings.

  • If the first three weighings involve only three coins, we must have compared each of these three coins against the other two. We will know the rank order of these coins ( A < B < C A < B < C , say), but will know nothing about the other three coins D , E , F D,E,F . The second lightest coin could be any of A , B , D , E , F A,B,D,E,F . If it was the case that all three of D , E , F D,E,F were less than A A , it would take three weighings to determine the middle coin of D , E , F D,E,F , plus at least one weighing to establish that all of D , E , F D,E,F were less than A A . It would take at least 7 7 weighings to solve the problem.
  • If the first three weighings involve four coins, testing A v B A \,v\, B , A v C A \,v\,C and A v D A\,v\,D , we might obtain that B , C , D < A B,C,D < A . Thus any one of B , C , D , E , F B,C,D,E,F could be the second lightest, and it will take four or more weighings to decide which it is. It will take at least 7 7 weighings to solve the problem.
  • If the first three weighings involve four coins, testing A v B A \,v\,B , C v D C\,v\,D and A v C A\,v\,C , we might obtain that B , C < A B,C < A and C < D C < D .Thus any one of B , C , E , F B,C,E,F could be the second lightest (and, indeed, D D could be the second lightest if C C is the lightest). Since we have obtained no information so far about the relative weights of B , C , E , F B,C,E,F , it will take at least 4 4 more weighings to sort this out, and so we will need at least 7 7 weighings to solve the problem.
  • If the first three weighings involve five coins then, without loss of generality, they test A v B A\,v\,B , A v C A \,v\,C and D v E D \,v\,E . We might obtain that B , C < A B,C <A and D < E D < E . in which case any one of B , C , D , E , F B,C,D,E,F could be the second lightest. If B , C , F B,C,F were the three lightest, it would take 3 3 weighings to determine the middle coin of the three, and at least one more weighing to ascertain that D D and E E were not involved. We would need at least 7 7 weighings to solve the problem.
  • If the first three weighings involve all three coins, the first paragraph explains how 7 7 weighings are not just necessary but also sufficient.

I agree with "Since we do not know the weights of the various coins, there is no advantage to be gained by comparing the weights of groups of coins, so we must always simply compare one coin with another.", but I'm wondering if there is some (relatively simple) way to formalize this?

Eli Ross Staff - 3 years, 6 months ago

Log in to reply

A few examples sort this out. If we consider a set-up with four weights, and weigh A B v C D AB \,v\,CD , A C v B D AC\,v\,BD and A D v B C AD\,v\,BC :

  • if the weights are 1 , 3 , 4 , 5 1,3,4,5 , then the lightest weight ( 1 1 ) is the weight common to the lighter pairs in all three weighings, but we cannot identify the heaviest weight ( 5 5 ).
  • if the weights are 1 , 2 , 3 , 5 1,2,3,5 , then the heaviest weight ( 5 5 ) is the weight common to the heavier pairs in all three weighings, but we cannot identify the lightest weight ( 1 1 ).
  • if the weights are 1 , 2 , 3 , 4 1,2,3,4 , then one of the weighings is a balance. The lightest weight ( 1 1 ) is the weight common to the lighter sides of the two unequal weighings, while the heaviest weight ( 4 4 ) is the weight common to the heavier sides of the two unequal weighings.

With such different outcomes/deductions from the same sets of experiments, we cannot hope to gain information from weighing the coins in groups. Of course, if we knew the exact weights of the coins, we could probably adopt a more efficient strategy...

Mark Hennings - 3 years, 6 months ago

This is one of only two solutions that even considered proving that 7 weighings are necessary, and the only one that actually went on to prove it (the other one didn't know how to prove it). Others were only proving it's sufficient (by finding an algorithm). That's why you got an upvote from me.

Tomaž Cedilnik - 2 years, 8 months ago
Pepper Mint
Nov 22, 2017

6 coins are A, B, C, D, E, and F.

Divide them into 2 groups: A, B, C / D, E, F.

Compare A and B, then compare heavier one between the 2 and C. The heaviest coin be expelled, and I've made 2 tries.

Do the same work with D, E, and F. Now, Here are 4 coins left, with 4 tries in total.

Now, compare 3 coins out of 4. with 2 tries, I may expel the heaviest coin. And since I know the relative weight of lighter 2 coins, now compare the heavier one of the two and F. Finally, expel the heavier one.

I have 2 lightest coins, knowing which is heavier. And therefore total tries are 2 × 2 + 2 + 1 = 7 2 \times 2 + 2 + 1 = 7 .

That doesn't work... e.g. 1st A>B, A>C. Expel A. 2 tries. 2nd D>E, D>F. Expel D. 4 tries. 3rd (B,C,E) To find and expel heaviest: B>C, B>E, expel B. 6 tries. Now we have (C,E,F). And know nothing about relative weights of C and E... C>E and then C>F. 8 tries. We know nothing about the relative weights of E and F. E>F. 9 tries. So E. This solution doesn't work.

Instead of expelling heaviest, finding and keeping the lightest works: 1st A<B, A<C. Keep A. 2 tries. 2nd D<E, D<F. Keep D. 4 tries. 3rd A<D. A is lightest. 5 tries. 4th 2nd lightest is either B, C or D. So compare. B<C, B<D. 7 tries.

Alex Burgess - 3 years, 6 months ago

Log in to reply

I agree with "That doesn't work"

David Richner - 3 years, 6 months ago

On the last step, if you compare b and c and b and d and b>c and b>d, then you still don't know which is second lightest and have to take an eighth try to compare c and d. So I don't think that works either

Masom Rodriguez Rand - 3 years, 5 months ago

Log in to reply

Was this problem SO hard that led us to a contradiction? I'm just getting more and more confused.

Pepper Mint - 3 years, 5 months ago
Peter Byers
Nov 24, 2017

If we designate the minimum value of M M , for x 2 x \ge 2 coins, as m ( x ) m(x) , then for any integer y x y \le x ,

m ( x + y ) m ( x ) + y + 1 m(x+y)\le m(x)+y+1

(which establishes the bound that Ivan Koswara already gave, m ( x ) x + log 2 x 2 m(x) \le x+\lceil \log_2 x \rceil -2 , and in particular m ( 6 ) 7 m(6)\le 7 , but I have not found a way to prove minimality).

P r o o f . Proof.

Step (1): Test any y y distinct pairs of coins, and set aside the heavier coin from each test.

Step (2): Take the x x coins that have not been set aside, and perform the appropriate m ( x ) m(x) tests to determine which out of those coins is the lightest and which is the second lightest, and designate them as CoinA and CoinB respectively.

Step (3): CoinA is the lightest out of all x + y x+y coins, and the second lightest must be either CoinB or the coin (if there was one) that was tested against CoinA in Step (1), so testing these two coins against each other completes the task.

I think it should be \geq , not \leq . This is because in step (3), you are finding the lightest coin out of y + 1 y+1 coins (CoinB + y y that you set aside in step (1)). This can be done in no less than y + 1 y+1 steps. In the worst case scenario, i.e. when you literally compare every one of the y + 1 y+1 coins, this takes y ( y + 1 ) / 2 y(y+1)/2 steps. So using this procedure, we establish the bound m ( x ) + y + 1 m ( x + y ) m ( x ) + y ( y + 1 ) / 2 m(x)+y+1\leq m(x+y) \leq m(x)+y(y+1)/2 . This, by the way, gives you the minimality you were looking for.

The only issue now is to show that this procedure does in fact yield the minimum m ( x ) m(x) .

Milly Choochoo - 3 years, 6 months ago

Upvote for generalizing it and for recognising you need to prove necessary and sufficient number of weighings (even though you haven't proven both).

Tomaž Cedilnik - 2 years, 8 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...