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
re(3): Solution based on the OSort sorting algorithm by Charlie)
This conversation probably doesn't belong here, but here is the Osort in Visual Basic anyway:
' OSort (Version 2)
Step = Int(Length / 2  1) ' Set initial step size
While (Step > 0)
For I = 1 To Length  Step ' Set the range of the lower search cells
If IntArray(I) > IntArray(I + Step) Then ' Compare cells
Temp = IntArray(I) ' \
IntArray(I) = IntArray(I + Step) '  Swap Cells
IntArray(I + Step) = Temp ' /
End If
Next
Step = Int(Step * 0.86) ' Decrement the step size
Wend
In the tests I have done comparing it to the Shell sort, this algorithm is much faster. It's not quite as fast as the Quick sort for completely randomized data, but for data that is mostly sorted, the OSort is faster than the Quick sort.
Version 3 of the OSort is even faster, but it requires an additional few commands. I'll send you a link, if you like, to the data where I compare the three algorithms.

Posted by Erik
on 20040603 09:37:02 