12 Steel Balls Logic Test

While checking my web statistics today I noticed that the top search keyphrase I’m getting traffic from is “Mind Puzzles”, so maybe it’s time for a new one today.

The 12 steel balls puzzle is known as a logic test, a simple puzzle that doesn’t require any extraordinary math knowledge, but instead it tests the mind logic and the ability to analyze problems, that’s why it’s recommended for developers to test their logic and ability to see all possible solutions of a problem and choose the right route to go through.

The Puzzle

As you can tell from its name, the puzzle is about 12 steel balls, identical in almost everything, color, size and shape, but as for weight they are all identical except for one, which is different without knowing whether it’s a heavier or lighter ball, Now we have a balance scale that we can use for only three weighings to identify the different ball and whether it’s a heavier or a lighter ball.

It may sound simple but it’s not as simple as it sounds, you can find more about this puzzle, its history and some hints and tips to solve on Paul Harkins’s website, I created a PDF version of the same file for non-windows user as well.

The Solution

Naturally I won’t post the solution today with the puzzle, I prefer to keep it until next Saturday (a week from now), although your emails and comments are welcomed, comments with right solutions on this post will not show up before the solution date, so if you are really the type of person that like logic challenges and mind puzzles, give it a shot and I’m postitve you will enjoy it.

UPDATE: It seems that this is not the type of puzzles that encourage commenting, I didn’t get a single comment on this. Because of that I will not spoil the beauty of this here, if you gave up and didn’t find the solution contact me privately and I’ll send you the solution, in case I received a lot of requests then I will post the solution here.

UPDATE 2: Great news, I got the first right solution from a friend of mine, Iyad Kallas (aka GraYFoX), he nailed it down and it’s your turn now, I still don’t want to post the solution not to spoil the joy of solving it, so if you are still thinking about it, maybe it’s time to finish it..

Comments

30

  1. andy said..

    Divide up the balls in 3 groups of 4 balls each. Weigh each group. One group will be either heavier than the other two, or lighter, in which case the different ball is heaver or lighter respectively.

    That’s easy…

  2. andy said..

    oh wait. we have to find the different ball too. hmm. lemme think about it

  3. GraYFoX said..

    buddy
    i hope this it the right solution
    it will make me feel good about myself if it is , so please let me know if it is right
    1- you divide balls into 2 main groups , 6 balls in each group
    2- you isolate the heavier group of 6 balls, knowing it has the heavier ball, you split it in two groups of 3 balls, and weigh again, the heavier group of 3 will contain the heavier ball
    3- you take the heavier group of 3, and take random two balls of it and weight them , and now there will be a switch statement with two cases
    Case1: the two balls will be the same weight , which means the 3rd ball weighs more
    Case2 : one of the two balls will weigh more which means it’s the heavier :D
    h3

  4. Rida said..

    Andy, Good luck you are going the right path..

    GraYFoX, sorry dude, but your solution doesn’t study if the car is heavier or lighter. Why did you take the heavier group after the first weigh? what if the ball is lighter? it’s in the second group then right?

    Good luck to you all.

  5. cutenk2 said..

    Hey there :)
    It’s 3:16 am and I am really sleepy and really sleepless .. But I gess the balls should be devided into two groups , each to a side of the scale.. one is heavier than the other for some reason ..
    hmmm .. well here we have a question .. do we know if the different ball is lighter or heavier than the others …
    In case it was heavier we’d take the heavier group of six and devide it again and put each half to a side .. then take the heavier three ..
    hmmmm .. choose two of them and weigh them.. if they are the same then the different is the third one.. else .. one of the heavier balls ..
    In case it was lighter we’d do the whole thing but chose the lighter group …
    But I still haven’t worked out how to tell whether the different ball is heavy or light yet … Hmmmmmm

  6. Qabbani said..

    hmmm sound cool

    okay

    make them 3 part’s

    4 4 4 , take first 2 4’s each one in a side now

    (1) IF same then the 4 out had the different one we make it 2 2 , then we can get the different 2 and get it out …

    (2)ELSE not same , hmmmm
    BRB

  7. slique said..

    I’m pretty sure I have the right answer, though I don’t want to post it here and spoil the fun for everyone else. Is there an email address I can send it too?

  8. Rida said..

    Hey slique, feel free to use the contact form in the about page.

  9. Jazz said..

    Step A: Take 4 & 4 - it balances
    then we know that’s in the third lot of 4.

    Step B: take 2 balls from Step A and 2 from the third lot of 4.
    If it balances then we know that it is in the 2 balls which we did
    not weigh from the third lot.

    StepC (1): Take one of the balls from Step B and then weigh it with 1
    of the remaining 2 balls( of the third lot). if it does not balance
    then we know which is the heavier or light ball & the odd ball. But if
    it does balance then the ball not weighed as yet will be the odd ball
    but I cant tell if it heavier or lighter.

    Going back to STEP B.
    If in step B it does not balance then. Then we know whether is heavier
    of lighter.

    STEP C(2):
    We then take one balls from STEP A and and weigh it weigh it with 1 of
    the balls of the 2 in STEP B - the heavier of lighter set.

    If it balances then we know the 1 remaining is odd. If it does not
    then the scale tilt which will reveal the odd ball.

    This will only work if in the STEP A the balls balance on the first attempt.

    Its a bit complicated to explain this over e-mail but I hope u understand.

  10. Rida said..

    Jazz, nice approach, all I can say that you are close, but you still have the most difficult part on when the weigh on Step A doesn’t balance.

    Good luck…

  11. embeejay said..

    The solution is fairly straight forward, just give each ball its own number, divide them in to 3 * 4 and start out buy weighing set 1 and 2 against eachother… if they are equal the odd ball is in set 3, if set 1 is heavier than set 2 then the odd ball is eitehr in set 1 and is heavier than the rest or in set 2 and is lighter than the rest.,.. go from there and you’ll figure it out ;)

  12. Rafee said..

    Hi,
    Why don’t you post the solution….I ve been waiting you post the solution for a couple of weeks and nothing new here yet….I ve got the link to this post from grayFox blog..at the beginning …I read only your description for the puzzle and after few trials I could end up with a solution but it was not a big issue for me to post it till yesterday. when I checked your post again…I read about the puzzle quietly and I read what Mr. Paul Harkins’s mentioned in the attached file…so I appreciated more …and I looked to it differently…so till yesterday I was with one solution which is like the first draft of a code that does what exactly required but when you look in the syntax…we might prefer to overlook it…so knowing that there might be more than one solution…I tried again and I came out with two other solutions for your puzzle…..I will first described the most optimized way that I could think about so far

    1- Divide them into three groups of 4
    2- Weight two…name them RHS & LHS…
    3- RHS has balls 1, 2 ,3 and 4
    4- LHS has balls A, B, C and D
    5- If both are not equal and lets say RHS was heavier than LHS
    1- replace 1 from RHS with A from LHS
    2- replace 2, 3 and 4 from RHS with 3 balls of the third group (that contains the balls with known and equal weight)
    3- now there might be three cases:
    case1: RHS still > LHS //nothing has changed =>
    1- the two balls which were replaced (1 & A) have the same weight ..so we discard them from our range
    2- The three balls which were taking out of RHS are the same weight of their replacements….so we discard them too from our range
    3- We conclude from the results above that the different ball might be one of B,C or D from LHS and it is lighter
    4- Weight B with C and see which one is lighter
    5- If B & C were equal =>D is lighter

    Case2: if RHS A & 1 caused the change set =>
    1- either 1 is heavier or A is lighter, we weight either one with one of balls with known weight x ..lets take 1 with x..if both equal =>A is lighter..else 1 will be heavier
    case 3: RHS = = LHS => the heavier one is among the three balls which were taken out of RHS (2, 3 or 4) …we follow the same steps as in case1 to extract the heavier one this time.

    Now if RHS = =LHS
    This easy…name them 1,2 ,3 and 4
    1- put 1 and 2 on RHS
    2- put 3 with one of known weight on LHS
    3- if RHS >LHS =>1or 2 is heavier or 3 is lighter
    1- put 1 on the RHS and 2 on the LHS ..if equal =>3 is lighter otherwise the heavier side will have the heavier ball ……….

    SOLUTION no2
    Start from step 5 in solution no1
    If RHS > LHS
    1- take C and D from LHS out
    2- put 3 & 4 from RHS on LHS
    3- put B from LHS on RHS
    4- Now we will have A,3,4 on LHS…..1,2,B on RHS
    5- If RHS still > LHS =>1 or 2 is heavier …or A is lighter
    6- If LHS > RHS => 3 or 4 is heavier or B is lighter
    7- If RHS = = LHS =>C or D is the diff one and lighter…and that is easy to extract it in one trial

    Solution no3
    x is one of known weight
    Again start form step #5
    1- put 2 , A and x on RHS (take 3,4 out)
    2- put B, C and 1 on LHS (we take D out)
    3- if RHS still > LHS => the taken balls out had no effect …A and 1 have no effect too..we will be left with this conclusion, either 2 is the heavier one or (B or C ) is the lighter
    4- if LHS > RHS => either 1 is the heavier or A is the lighter
    5- if RHS == LHS =>either 3 or 4 is the heavier or D is the lighter
    6- in all cases our ranged is reduced to three balls…two will have the same probability of being heavier or lighter and the third with be the opposite. in all case we put the one might be the heavier with on that might be the lighter on the same hand side with two of known weight….this way we will know….

    U might find bug with any of the solution and hopefully it would be syntax errors….hope it will run fine there..BTW I hate documentation

  13. Jazz said..

    Are u going to give us the ans?

  14. paul said..

    hi, I think I have figured it out..just stumbled across this problem a while ago. Just reading some of the comments, the logic behind 3 groups is correct, however, the quantity within each group is not…hope this does not give two much away but brings a small bit of light upon the solution!!

  15. Jazz said..

    Number the balls 1 to 12. Weigh 1, 2, 3, and 4 against 5, 6, 7, and 8.
    If (1, 2, 3, 4) and (5, 6, 7, 8) balance:
    Weigh 9 and 10 against 11 and 8 (we know 8 is not the odd ball).
    If (9, 10) and (11, 8) balance: then 12 is the odd one.

    Weigh 12 against any other to find out if it is heavy or light.

    If (9, 10) and (11, 8) do not balance: suppose 11 and 8 are heavier,
    than 9 and 10; then either 11 is heavy, or 9 is light, or 10 is light.

    Weigh 9 against 10; if they balance, 11 is heavy; if they do not,
    the lighter of 9 and 10 is the odd ball.

    (Similar argument if 11 and 8 are lighter than 9 and 10).

    If (1, 2, 3, 4) and (5, 6, 7, 8) do not balance:
    Suppose 5, 6, 7, and 8 are heavier than 1, 2, 3, & 4. Then: one of
    (1, 2, 3, or 4) is light, or else one of (5, 6, 7, or 8) is heavy.
    Weigh 1, 2, and 5 against 3, 6, and 9.
    If they balance: then either 7 is heavy, or 8 is heavy, or 4 is light.
    Weigh 7 against 8; if they balance, 4 is the odd ball, otherwise the
    heavier of 7 and 8 is the odd ball.

    If (1, 2, 5) and (3, 6, 9) do not balance: suppose 1, 2, and 5 are lighter
    than 3, 6, and 9; then either 6 is heavy, or 1 is light, or 2 is light.
    Weigh 1 against 2 to find out which one of the three choices is true.
    Otherwise, suppose 1, 2, and 5 are heavier than 3, 6, and 9; then either 3
    is light, or 5 is heavy.

    Weigh 3 against (say) 2 to find out which of the two choices is true.

    (Similar argument if 1, 2, and 5 are lighter than 3, 6, and 9).

    I think this is right.

  16. maddy said..

    i have tried and failed on this one, someone please give me the answer…im having trouble thinking of anyhting else

  17. Jazz said..

    Maddy,

    I am a 100% sure that the solution I posted is right.

  18. Azimuth said..

    its pretty simple.

    Name the balls 1-12. Divide them into groups of 4.
    weight the 1-4 against 4-8. If they balance then 9-12 is the odd one out. seperate 9-12 into 2 ball groups. Weigh those balls against each other, lets assume 9-10 is heavier than 11-12. We seperate 9 and 10 and weigh them then we get the odd ball from those.

    thats it…

  19. Darren Amundson said..

    This is easy. make 3 groups of 4. weigh two of them. if one is heavier the ball is in that group. if the two groups weigh the same it is in the third group (not weighed). Take the group of 4 that has the ball in it and split into 2 groups of two. Find the heaviest. Then split that and identify the ball.

    However, you should make it more challenging, by making it 9 balls and only two weighings.

  20. john said..

    the problem with the last 2 posts is that the ODDBALL is EITHER heavy OR light, so you cannot simply assume as many others have that the ball is heavier.

  21. Paul H. Harkins said..

    Thanks for your interest and comments on this very interesting and difficult puzzle.

    Play the Java Interactive 12 Steel Balls Logic Puzzle on your own PC, and learn how to program in the Java Programming language at http://www.harkinsaudit.com

    I put this puzzle in my book “How to Become a Highly Paid Corporate Programmer” and talented programmers have solved it with computer programs in the Java, Python, and C programming languages.

  22. thomas said..

    can u please email me the answer. me and my friends have been trying to figure out the correct answer but we can only get half of it. like the correct ball is in the last group of 4 that is not weighed so basically it all has to work out perfectly. not sure of the solution when u split the balls into 3 groups of 4 and it is uneven from there. what is the solution?

  23. Mike Hedges said..

    LLL
    LLB
    LLR
    LBL

    RBB
    RBL
    RRB
    RRL

    BBR
    BLR
    BRB
    BRR

    Mark the balls and divide into sets of 4 and weigh against each other according to the below:-

    1 2 3 4 v 5 6 7 8
    1 2 3 10 v 7 8 11 12
    1 4 6 8 v 3 9 10 12

    Each weighing will even be
    Left Hand Side Down = L
    Balanced = B
    Right Hand Side Down = R

    For instance if it goesLeft / Balance / Right = ball 6 is light

    If it is Right/ Balance / Left = ball six is heavy

    Each combination is unique.I discovered this solution after about 3 years when I considered that 3 things could happen on each weighing, giving 27 possibilities. Ignoring the Balanced / Balanced /Balanced outcome that leaves 26. There are 24 possibilities for the rogue ball – so it may be soluble. I have no idea if this answer is generally known or if there is any other way of solving the problem.

    mike.hedges@cwctv.net

  24. Mike Hedges said..

    Further to my answer above I made a slight error. The weighings should be:-

    1 2 3 4 v 5 6 7 8
    2 3 7 10 v 1 8 11 12
    1 4 6 9 v 3 8 10 12

    Renumbering the balls in a more memorable way would be weighings:-

    First 1 2 3 4 v 5 6 7 8

    Second 1 4 7 10 v 3 6 9 12

    Third a. 1 5 11 12 v 3 4 8 9
    [or Third b. 1 5 10 12 v 3 4 8 11]

    Each outcome is unique and can be decoded from the table below to identify the offending ball:-

    Ball 1 Heavy LLL Light RRR
    Ball 2 Heavy L– Light R–
    Ball 3 Heavy LRR Light RLL
    Ball 4 Heavy LLR Light RRL
    Ball 5 Heavy R-L Light L-R
    Ball 6 Heavy RR- Light LL-
    Ball 7 Heavy RL- Light LR-
    Ball 8 Heavy R-R Light L-L
    Ball 9 Heavy -RR Light -LL
    Ball 10 Heavy -L- Light -R-
    Ball 11 Heavy –L Light –R
    Ball 12 Heavy -RL Light -LR

    Left Hand Side Down = L
    Balanced = -
    Right Hand Side Down = R

    I can’t see a pattern for third weigh except 3[a] has one ball left off out of each set of three - 1-3,4-6,7-9,10-12.

  25. Jen said..

    Split the balls into 3 groups of 4. Weigh group A on the left against group B on the right.

    If they are equal :

    then they are “duds”. In this case, take three of the remaining, put them on the left and weigh againt three of the duds. If this weighing is equal, the last ball is the odd one out and we can use a dud to determine if it is heavier or lighter. If this weighing (2) is unequal, this will tell you if the odd ball out is heavier or lighter. Take two of the potential odd balls and weigh them against each other. If they are equal, the third is the odd ball, otherwise, you can tell from this weighing which is the odd ball because we now know if it is heavier or lighter.

    If A and B are unequal :

    Remove 2 balls from A and one from B. Swap one of the remaining balls from A with one of the remaining balls from B and weigh again.

    If the balance changes :

    then the odd ball is one of the swapped balls. Weigh one of them against one of the remainder from the first weighing and we can determine which is odd and whether it is heavier or lighter.

    If the balance is equal :

    the odd ball is one of the ones you removed. Weigh the two you removed from A against each other. If they are equal, the odd ball is the one you removed from B. If they are unequal, you have found the odd ball and you know if it is heavier or lighter because you know whether A was lighter than B.

    If the balance doesn’t change :

    The ball is either the last remaining unswapped ball from A, or one of the last two remaining unswapped balls from B. Weigh those last remaining unswapped balls from B . If they are equal, the odd ball is the last remaining unswapped ball from A and we now know if it is heavier or lighter (we know if A went up or down). If they are unequal, you have found the odd ball and you know if it is heavier or lighter because you know whether B was lighter than A.

    Hope this is correct!

    Now for a REAL challenge, try it with 4 weighings and 39 balls. It’s tricky, but doable.

  26. MustAsk said..

    You say, if A and B are unequal, to remove 2 from A and 1 from B and swap the remaining balls from A with one of the remaiing balls from B and to re-weigh. That wont work because I would be weighing 2 balls against 3.

  27. Jen said..

    Let’s call the 4 balls that weren’t used in the first weighing group C. If A & B are unequal, we know that all balls in C are equal, so they are “duds”. Simply use one of these in the next weighing to be the 3rd ball.

  28. Spinner said..

    Please clarify- how is Grayfox correct? I thought the puzzle states that you do not know if the ball is heavier or lighter.. His equation states you would know which group was heavier. How would you accompish this? You still wouldnt know if the ball was heavier or lighter. I dont think he is correct.

  29. spinner said..

    i have the answere to this problem. it is not as ez as it sounds. one clue i will give you is: when using the ballance you must obtain all the information it provides.

  30. OC said..

    here is how you solve it:
    first, you divide the balls into 3 sets with 4 balls each. You can number them from 1 to 12 to make things easier to follow. During the first use of the scale, you put the set consisting of balls 1,2,3, and 4 on one side and the set of balls 5,6,7, and 8 on the other side. There are 2 possibilities: the first possibility is that the 2 sets are equal in weight, so you know that the odd ball is in the third set of balls 9,10,11, and 12. For the second use of the scale, you put balls 6,7, and 8 on one side, and balls 9,10, and 11 on the other side. If they are equal, then the odd ball is ball # 12, but if they are not equal, then you also have 2 possibilities, either balls 6,7,and 8 are heavier than balls 9,10, and 11, so you know that the odd ball is either ball 9, 10, or 11, and you also know that the odd ball is lighter than the other balls. So for the third use of the scale, you put ball 9 on one side, and ball 10 on the other side, and if they are equal in weight, then ball 11 is the odd ball, but if they are not equal in weight and one is heavier than the other, then the lighter one is the odd ball whether it is ball 9 or ball 10 (whichever one is the lighter of the two). The other possibility is when you use the scale the second time and weigh balls 6,7,8 and balls 9,10,11, then if the set of balls 9, 10, 11 are heavier, then the odd ball is heavier than the rest, and so for the third time you put ball 9 on one side and ball 10 on the other, and if they are equal in weight then ball 11 is the odd ball, but if they are not equal, then whichever ball of the 2 that is heavier, then that is the odd ball whether it is ball 9 or 10. Now if you go back to the first time we used the scale to see the other possibility which is that the 2 sets of balls are not equal. So set one of balls 1,2,3, and 4 is not equal in weight to the second set of balls 5,6,7,and 8. One set of balls is heavier than the other, and it doesn’t really matter at this point which is heavier, so lets assume that set 1 consisting of balls 1,2,3, and 4 is heavier than the other set of balls 5,6,7, and 8. We also know that since sets 1 and 2 are not equal in weight, then one of them contains the odd ball, and therefore balls 9,10,11, and 12 are all of equal weight. Now for the second use of the scale, we put balls 3,5, and 10 on one side, and we put balls 2,4,and 6 on the other side of the scale. We leave balls 1,7 and 8 as a set on the side for now. If the set of balls 3,5, and 10 is equal in weight to the set of balls 2,4, and 6, then that means the odd ball is one of the balls 1,7, and 8. So for the third use of the scale, we put ball 7 on one side and ball 8 on the other, and if they are equal in weight, then we know that ball 1 is the odd ball and that it is heavier than the rest, but if balls 7 and 8 are not equal in weight, then the lighter one of the two is the odd ball which is lighter than the rest of the balls. Now if we go back to the second time we used the scale, if the 2 sets were not equal in weight, then that means the odd ball is one of these balls: 2,3,4,5, and 6. Ball 10 was not included as a possible odd ball since it was already eliminated in the first measurement where we determined that balls 9,10,11, and 12 are normal and equal in weight. Now, for the second measurement, if the set of balls 3,5, and 10 is heavier than the other set of balls 2,4, and 6, then by looking at the first 2 measurements together, we can eliminate balls 2,4, and 5 as possible odd balls. The we are left with balls 3 and 6, one of them being the odd ball. All we have to do now is weigh either one of them, lets say ball 3, weigh it with ball 10(which we know is a normal ball). If balls 3 and 10 are equal in weight, then we know that ball 6 is the odd ball and it is lighter in weight than the rest of the balls. But if balls 3 and 10 were not equal in weight, then we know that ball 3 is the odd ball and it would be heavier than the normal balls. Now to consider the last possibility, lets go back to the second time we used the scale and put balls 3,5, and 10 on one side and balls 2,4, and 6 on the other side. If the set of balls 2,4, and 6 was heavier than the other set, then by looking at both measurements 1 and 2, we can eliminate balls 3 and 6 as possibilities for being the odd ball. so we are left with balls 2,4, and 5 as possibilities for being the odd ball. So for the third use of the scale, we put ball 2 on one side and ball 4 on the other, and if they are equal in weight, then ball 5 is the odd ball and it is lighter than the rest of the balls. But if balls 2 and 4 are not equal in weight and one is heavier than the other, then whichever is the heavier one of the two balls 2 and 4, then that would be the odd ball, and it is heavier than the rest of the normal balls. And that is how we can find which one is the odd ball by using the scale only 3 times.

Leave a Reply

you can use these xhtml tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Articles Permanent Link