Laran Evans
I develop software people love to use.
  • Home
  • About
  • Contact
  • Resume
  • Testimonials
Skip to content
  • Entrepreneurship
    • Leadership
    • Project Management
    • Team Development
    • Time Management
  • Motorcycles
    • Restoration Projects
  • Puzzles
  • Software Architecture
    • Cloud Computing
  • Software Development
    • Algorithms
    • CSS
    • Java
    • Javascript
    • MySQL
    • PHP
    • Python
    • Ruby and Rails
    • System Administration
« Three Light Bulbs
Four From Five and Three »

Eight Billiard Balls

By laran | Published: 2007/10/30

The Problem

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?

The Solution

My original solution to this problem was this:

Binary search. Put all eight balls on the scale. Take four off. If they weigh more than half the weight of all eight leave those four on. If they weigh less than half the weight of all eight take those four off and put the other four on. Take two balls off. If the two weigh more than half the weight of the four balls leave them on. If the two weigh less than half the weight of the four balls take those two off and put the other two on. Take one ball off. If the one ball weighs more than half the weight of the two, the heaviest ball is on the scale. Otherwise it’s in your hand. The fewest number of times you have to use the scale is 4 (to get the weight of 8 balls, 4, 2 and then 1).

Terry Stoeckert, statistician friend of mine showed me a better way to do this. He also pointed out an error in my process.

First the error. I used two different kinds of scales. In the problem statement I refer to a balance scale. In the solution I refer to a weight-scale. Duh!

Terry’s solution was to stick with the balance scale and put three balls on each side, leave two balls off the scale.

If the two sides of the scale are equal in weight, take the six balls off the scale, take the two balls you left off the scale for the first weighing and put one on each side. Whichever side is heavier tells you which ball is heavier.

If one side was heavier than the other in the first weighing, clear the lighter side, take one ball off the heavier side and move it to the lighter side. Take another ball off the heavier side and hold it in your hand. If the two sides are equal in weight, then the heavier ball is in your hand. If one side is heavier than the other however, then the heavy ball is on the heavier side.

So, with Terry’s solution, the heavy ball can be found in two weighings. Nice work Terry.

This entry was posted in Puzzles and tagged Puzzles. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.
« Three Light Bulbs
Four From Five and Three »

Post a Comment

Click here to cancel reply.

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • About Me

    I've got a masters degree in computer science and over 10 years of experience building web-based systems using Java/J2EE, Ruby, Rails and PHP. I'm a strong believer in the effectiveness of Agile Methods. Read more »

  • Subscribe

  • Table of Contents
    • The Problem
    • The Solution
  • Similar Posts
    • 100 Bright Ideas
    • The Manhole Cover
    • Seven Days of Gold
    • Spinning Disc
    • Analog Clock
  • From Around the Web

      Shared Items
    • Recent Posts

      • The carbs are clean!
      • 80 pages of Ruby on Rails Performance Optimization Tips
      • Ruby Garbage Collection In-Depth
      • Binary Logic Basics
      • Kuali in Nacubo Magazine
    • Older Posts By Month

      Let's Talk

      Ask a question below. You'll be prompted for your name and email after you click the "Ask" button.

    Know more. Accomplish more. Succeed.