There are 6 coins weighing 1, 2, 3, 4, 5 and 6 grams that look the same, except for their labels. The labels are supposed to display the weights of the coins.
How can you determine whether all the labels are correct,
using the balance scale only twice?
(In reply to re: short solution - spoiler
A modification of the program to speed it up, and allowing it to continue to completion verifies that these are the only two solutions:
1 & 3 v 5 RHS heavy
1 & 2 & 5 v 3 & 6 RHS heavy
1 & 2 & 3 v 6 Equal
1 & 6 v 3 & 5 RHS heavy
In each case if the first weighing does not go as shown, the coins are mislabeled and the next test is not needed. If both tests are met, the coins are correctly labeled.
The speed-up modification is to require that the left pan be no heavier than the right pan in either weighing and that the left pan in the second weighing be no lighter than the left pan in the first weighing. This saves much inner looping. It also reduces duplication, the only case of which is where there was equality between left and right pans.
Posted by Charlie
on 2016-01-14 19:59:00