Find the ball with odd weight! (9 balls puzzle) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Find the ball with odd weight! (9 balls puzzle)

You are given 9 balls, out of which 8 have same weight and 1 ball's weight is either more or less than the remaining 8 balls. You have a weighing scale. What is the minimum number of times you need to use the scale to find the ball with odd weight?

9th Feb 2017, 6:57 PM
Manthan Raja
Manthan Raja - avatar
8 Answers
+ 4
@Zilvinas Steckevicius Perfect! I was looking for the same answer! Thanks :) @Mario Laurisch Your answer is right only if you are lucky. But I am unluckiest. :( So unfortunately, I would have to take 3 turns/iterations. :p Anyway, thanks for the answers. :)
9th Feb 2017, 7:36 PM
Manthan Raja
Manthan Raja - avatar
+ 3
the minimum is once: put four balls on either side of the scale. if the weights are the same, the remaining ball is the one with odd weight.
9th Feb 2017, 7:11 PM
Mario L.
Mario L. - avatar
+ 3
@Mario Laurisch Nice! Was expecting the same answer. But what if it is 1 of those 8 balls that are put on scale?
9th Feb 2017, 7:15 PM
Manthan Raja
Manthan Raja - avatar
+ 3
@Zilvinas Steckevicius Can you please explain how did you get the answer as 2?
9th Feb 2017, 7:16 PM
Manthan Raja
Manthan Raja - avatar
+ 2
then you'd have to weigh again. but you asked for the minimum. now you're asking for the maximum.
9th Feb 2017, 7:22 PM
Mario L.
Mario L. - avatar
+ 1
Well, first of all, I thought you are asking for complete algorithm, not just a lucky guess which can clearly be found with 1 try. And yet I'm wrong second time, because it would take 3 tries at least. I didn't pay attention to the "more or less" part. So basically we divide the balls into 3 groups by 3. In the first iteration we put 1st group on left side and 2nd on the right side. If we get lucky and the scales are balanced, the odd ball is in the group which is not on scales and we find it easily (we have 2 more iterations and only 3 possible options, so just take a random ball from 1st or 2nd group and compare it with 1-2 balls from the 3rd group). However, if scales are not balanced, we need to take 2 balls from one of the groups, lets say 1st group and compare them. If we are unlucky, and the odd ball is in the 2nd group, we do the same thing with 2nd group in 3rd iteraton. Now, if scales are not balanced, we must recall 1st iteration. If 2nd group was up, then the odd ball is lighter in weight than the others and vice versa. So 3 iterations.
9th Feb 2017, 7:28 PM
Zilvinas Steckevicius
Zilvinas Steckevicius - avatar
0
2
9th Feb 2017, 7:13 PM
Zilvinas Steckevicius
Zilvinas Steckevicius - avatar
0
So correct is 3 for more or less and 2 for more weight
10th Feb 2017, 6:05 AM
Priyanshu Agarwal
Priyanshu Agarwal - avatar