You have five coins, apparently alike, but actually of different weights. You also have a two arm scale.
Can you manage to sort the coins in ascending order, using the scale only seven times?
Bonus question: can it be done in fewer weighings?
(In reply to
Solution based on the O-Sort sorting algorithm by Erik O.)
Suppose A is the heaviest and E is the lightest, so you've got EDCBA. After your steps you get, since this is positional and A, C means first position vs 3rd position,
1. CDEBA
2. CBEDA
3. CBADE
4. BCADE
5. BACDE
6. BACDE
7. BACDE, which is still not ordered.
In the actual sort algorithm, each sort span must be iterated all the way through (I thought this was called a shell sort actually) until no flips take place through an entire sweep, especially at the end with increment of 1.
If they are not positional, then step 3 will produce a 10-20 split in the 30 possibilities that remain after the first two weighings, and if you're unfortunate enough that you fall on the 20 side, they can't be determined by only 4 more weighings.
|
Posted by Charlie
on 2004-06-02 11:22:26 |