8 Identical Balls Problem

Question: You are given 8 identical looking balls. One of them is heavier than the rest of the 7 (all the others weigh exactly the same). You a provided with a simple mechanical balance and you are restricted to only 2 uses. Find the heavier ball.

Answer: For convenience sake, let’s name the balls 1-8. First we weigh {1,2,3} on the left and {4,5,6} on the right. There are three scenarios which can arise from this.

If the left side is heavier, then we know that one of 1, 2 or 3 is the heavier ball. Weigh {1} on the left and {2} on the right. By doing this, we will know if 1 or 2 is heavier. If they balance out, then 3 is the heavier one.

If the right side is heavier, then we know that either 4, 5 or 6 is the heavier ball. Weigh {4} on the left and {5} on the right. By doing this we will know if 4 or 5 is heavier. If they balance out, then 6 is the heavier one.

Continue Reading Below

If {1,2,3} and {4,5,6} balance out, then we know either 7 or 8 is the heavier one. Weigh both of them to find out which one is heavier.

Confused yet? or was it too easy? This is one of the basic identical ball problems. Here  is a more complex problem involving 12 balls with one fake.

If you have any questions, please feel free to send me an email at support@mytechinterviews.com. If you have any interview questions which you feel would benefit others, I would love to hear about it.

If you're looking for some serious preparation for your interviews, I'd recommend this book written by a lead Google interviewer. It has 189 programming questions and solutions:

Book Cover
Button
6 Comments

6 Responses

  1. Radu says:

    Please help me. I have a cue epic and line is very small. Palade help me

  2. Dias says:

    Thanks for the good work…It helps.

  3. Milton says:

    This solutions works for 9 balls as well…

  4. Good question for efficiency measurement 🙂

  5. Aswin says:

    The first weighing is 3 vs 3 but then we go on to use the other 2 balls in the second weighing. That makes it 8 in total.

  6. Arun says:

    The question should be reframed to indicate 6 balls instead of 8 as you are only weighing 3 and 3….

Leave a Reply

Using Gravatars in the comments - get your own and be recognized!

XHTML: These are some of the tags you can use: <a href=""> <b> <blockquote> <code> <em> <i> <strike> <strong>