Puzzle

Duncan Chiu (dchiu@idt.net)
Tue, 22 Dec 1998 19:18:01 -0500


You may have seen this problem before. Give a try if you have not. I will send
you the solution in a week or so.

duncan

VB 98-99
Midterm Exam Project

Write a program to solve the puzzle.

Which One is The Odd Ball?

Twelve marbles all look alike. The color and the shape are the same. In fact,
you cannot tell the difference by just looking at them. Furthermore, all of
them, except one, have the same weight.

Can you find out which is the odd one if you are allowed to weigh them with
a balance only three times? Also, you have to find out if it is heavier or
lighter than the rest.

Your program should include three parts:

Part 1

Declare an array for the 12 marbles. Assign a weight to each of them using
the built-in random function, Rnd. Your program should display these weights
and the weights at each of the three weighings. Show the result of each run at
the end.

Part 2

Illustrate Part 1 in graphics. You may draw a line to represent a balance or
you can make it artistic and attractive (effort counts.)

Part 3

Modify your program (save it as a different file first) so that the user can
enter
the weights of the marbles. Make sure all possible user input errors are taken
care of in your program.
vbmidex98