Sunday, 7 January 2018

Puzzles | Find the faulty ball from 10 balls in minimum steps

There are 10 balls and one ball is faulty among them, determine the faulty ball in minimum steps. The faulty ball may be lighter or heavier than other 9 balls.

Divide balls into 3 groups (A, B, C) and each group contain 3 balls each, and one extra ball (X).

Compare groups A and B, and then compare B and C
   1. If A = B = C then X is the faulty ball.
      Return;
   2. If A != B and B != C
            then the faulty ball is in B,
      else if A != B
            then the faulty ball is in A,
      else if B != C
            then the faulty ball is in C.

We can identify the faulty group and the faulty ball is heavier or lighter based on if the faulty group is HEAVY/LIGHT compared to other groups.

   3. After finding out the group which contains the faulty ball and the properties whether
      the faulty ball is HEAVY or LIGHT.
      Choose any two balls (b1, b2) from the faulty group (the last ball left is b3).
      If b1 = b2
         then the faulty ball is b3.
      Else(No weight comparison required)
        If faulty group is HEAVY
               then pick the HEAVY ball is faulty
        If faulty group is LIGHT
               then pick the LIGHT ball is faulty.



Max comparisons required are 3.

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...