This week's book giveaway is in the Java in General forum.We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!

# find the heavier ball

rehans oberoi
Ranch Hand
Posts: 174
Suppose you had 8 billiard balls, and one of them was slightly heavier, but the only way to tell was by putting it on a scale against another. What's the fewest number of times you'd have to use the scale to find the heavier ball?

Srinivasa Raghavan
Ranch Hand
Posts: 1228
three

Srinivasa Raghavan
Ranch Hand
Posts: 1228
Put 4 balls each in Pan A & Pan B find the pan having the heaviest ball. Let it be pan b. So all 4 balls in Pan A are good balls, keep it seperate.
Now group the balls in pan b into two sets 2 in each pan. Find the Pan having the heaviest ball Let it be Pan A. Now you have identified 6 good balls.

Take one ball from Pan A and weigh it against any one of the 6 good balls if both are equal then the other ball is the culprit else this one should be the culprit.

fred rosenberger
lowercase baba
Bartender
Posts: 12122
30
once. if i was lucky.

Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
Two.

Put three on each side of the scale. If they match weigh the other two. If they don't match, weigh two of the heavy three.

Bert Bates
author
Sheriff
Posts: 8898
5
for extra credit, show how if you had 12 balls, and one was either lighter or heavier, you can find the odd ball with only three shots at the balance.