Stryder
10-12-2010, 12:12 PM
Again it's another Logic/Mathematics problem that might find itself used as a test for potential programmer applicants. The puzzle is thus:
There are 12 balls which all look visibly the same, however one of the balls is either Heavier or Lighter than the rest. You are required to use a set of Balance scales (That's two pans that weigh each side against one another) to weigh in no more than 3 weighings to find the Oddball and declare if it's Lighter or Heavier than the others.
Some Tips: (mouse over black text)
Tip 1a: 3 weighings is a hint
Tip 1b: While it's possible to plot multiple parallel weighings based upon the outcome, remember it's a logic problem that programmers should be able to fathom which means that it should be boiled down to a simple solution that can be easily programmed
Tip 2: You can number the balls to help (Afterall in programming they would be identified as independent variables)
Tip 3: Each weighing doesn't require the same balls in the same pan
I wrote a Javascript solution (http://sciforums.stryderunknown.co.uk/12balls.html) that was a mixture of my own attempt at solving the puzzle and eventually actual answer to confirm it was correct. (You can view the HTML source by typing view-source:http://sciforums.stryderunknown.co.uk/12balls.html in your URL box of your browser.)
(incidentally it's still not debugged properly, If the ball comes up J is lighter it can give the wrong readout, this is due to messy coding/formatting since the visable output is actually written differently to the array used for measuring.)
There are 12 balls which all look visibly the same, however one of the balls is either Heavier or Lighter than the rest. You are required to use a set of Balance scales (That's two pans that weigh each side against one another) to weigh in no more than 3 weighings to find the Oddball and declare if it's Lighter or Heavier than the others.
Some Tips: (mouse over black text)
Tip 1a: 3 weighings is a hint
Tip 1b: While it's possible to plot multiple parallel weighings based upon the outcome, remember it's a logic problem that programmers should be able to fathom which means that it should be boiled down to a simple solution that can be easily programmed
Tip 2: You can number the balls to help (Afterall in programming they would be identified as independent variables)
Tip 3: Each weighing doesn't require the same balls in the same pan
I wrote a Javascript solution (http://sciforums.stryderunknown.co.uk/12balls.html) that was a mixture of my own attempt at solving the puzzle and eventually actual answer to confirm it was correct. (You can view the HTML source by typing view-source:http://sciforums.stryderunknown.co.uk/12balls.html in your URL box of your browser.)
(incidentally it's still not debugged properly, If the ball comes up J is lighter it can give the wrong readout, this is due to messy coding/formatting since the visable output is actually written differently to the array used for measuring.)