The 8 ball problem, have a try!

Almost 2 months ago Kasper B. Graversen wrote in his blog about a puzzle that most people with computer science background get it wrong… Here’s how it goes, given 8 identical looking balls where one of them is heavier than the other seven and a scale, identify the one heavier ball using the least number of weightings. You can read about the puzzle at Kasper B. Graversen blog.

In order to simulate this problem I have created a JavaFX game, so before reading the solution have a try at my simulator and try to find the heavier ball.

You can find the code here
Note: You can also download the code from JavaFXExamples at google code.
svn checkout http://javafxexamples.googlecode.com/svn/trunk/ javafxexamples-read-only

Here are few screen shots of the game.

Drag and Drop the ball in the balance, left or right side

When pressing the “Start Balance” button you will see something similar to this screen shot.


About this entry