Link to home
Start Free TrialLog in
Avatar of hacktohack aa
hacktohack aa

asked on

16 balls weight puzzle

16 balls are given. All but one are of equal weight. You do not know whether the defective ball is lighter or heavier than the normal balls. You are given a comparison balance. You can use the balance only 3 times. How would you find out which is the defective ball? Is it heavier or lighter?
Avatar of ste5an
ste5an
Flag of Germany image

6-6, 2-2,1-1 or 6-6,3-3, 1-1
Avatar of Ramin
Ramin

You can use the balance only 3 times.

I think you can not find defective ball with using balance only for 3 times !
Sure, just start with 6 balls each as I wrote.
Avatar of hacktohack aa

ASKER

@ ste5an,  can you give few more hints to solve the problem.
Put 6 balls on each side of the scales.

Scenario 1 - the 2 lots of 6 balance: the odd ball is in the remaining 4; take 2 of the remaining 4 and balance with 2 from the original 12; if they balance the oddball is in the remaining 2; take one of those two and balance with one of the original 12, if they balance the odd ball is the other remaining ball but now used up 3 balances so can't check whether heavier or lighter. If they don't balance then you know which is the correct ball (1 from 12) and which is the test ball (1 from 2) and you can now say whether it is heavier or lighter.

Scenario 2 - the 2 lots of 6 don't balance: the odd ball is in the 12 but you don't know if it is heavier or lighter so don't know which side......
See link here with a solution for 12 balls, maybe logic can be extended to 16 balls:

https://www.mathsisfun.com/pool_balls_solution.html
Exactly I faced the same issue from scenario 2.
If each of the 3 times you use the balance it can have 3 possible results, that's 3^3 = 27 possible results total
If each of 16 balls can be either lighter or heavier, that's 16*2 = 32 possible condition total
Since 27 < 32, you can't generate a distinct result for each condition.
@ozo: It works.

The trick as that you use a tri-state logic and weight more than two balls at once.

1 Put on each side  6 balls. This can have three results: Left side is heavier (2), right side is heavier (2) or they are equal (3)

2 Take the 6 heavier balls, split them 3 on each side. Take the heavier 3 balls. Put 1 ball on each side. Then you have three results: Left side is heavier or right side is heaver, then the ball we're looking for is on the scale. If they are equal, our ball is the 3rd we didn't put on the scale.

3 As both 6 balls are equal, our ball must be in the 4 balls not on the scale. Thus put 2 on each side, take the heavier 2 balls and put 1 on each side. This our ball is now on the scale.

Makes using the scale three times.

In short: 6-6, 2-2,1-1 or 6-6,3-3, 1-1
@ste5an - that assumes that the odd ball is heavier than the rest, it could be lighter.
2 Take the 6 heavier balls, split them 3 on each side. Take the heavier 3 balls.
This assumes you know that the defective ball is heavier.
If you know that, then you have only 16 cases to distinguish, and 16<27
If you know the defective ball is heavier than lighter, then you could even solve it with 27 balls.
When the first two lots of six balance, you can determine whether the oddball is heavier or lighter with the next step:

Weigh balls 1 - 6 against 7 - 12. If these balance then use any 4 balls from 1 - 12 to balance against balls 13 - 16. We know these cannot balance as we know the oddball is in group 13 - 16. If 13 - 16 are heavier the oddball is heavier, if they are lighter then the oddball is lighter; but still don't know which one and now only have one use of the balance to determine. You can get it down to one of two by weighing 13 & 14 against 15 & 16; from the previous balance we know whether the oddball is lighter or heavier so we know which pair then contains the oddball. With a fourth use of the balance we can then say which it is.
Haven't seen this. After some thoughts, I can also only do it with using the scale four times.
Here is the solution with 4 times .

 
Name 16 Balls
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
 
Divide the balls in to 3 groups
 
G1:
1
2
3
4
5
6
A
B
C
D
E
F
 
G2:
7
8
9
10
11
12
G
H
I
J
K
L
 
G3:
13
14
15
16
M
N
O
P
 
 
First, weigh G1 and G2.
 
1st Case: G1 and G2 equals then we know the defective ball is in G3. To find out the defective ball weigh G2 (J,K,L) with G3 (M,N,O)
 
​Case: G2 (J,K,L)  ^   G3 (M,N,O)
​​​
​​1.a: G2 (J,K,L)  =  G3 (M,N,O) then the defective ball is P.
1.b: G2 (J,K,L)  >  G3 (M,N,O) then the defective ball is in G3 (M,N,O). to find out weigh M, N.
​​​​Case: M ^ N​​​​
1.b.1: M = N then the defective ball is O.
1.b.2: M > N then the defective ball is N.
1.b.2: M < N then the defective ball is M.
​​​​
  1.c: G2 (J,K,L)  <  G3 (M,N,O) then the defective ball is in G3 (M,N,O). to find out weigh M, N.
​​​​Case: M ^ N​​​​
1.c.1:  M = N then the defective ball is O.
1.c.2:  M > N then the defective ball is M.
1.c.2:  M < N then the defective ball is N.
 
2nd Case: G1 > G2, then we know the defective ball is in these 2 groups and G3 is non-defective group. To find out the defective ball from G1, G2. Remove I, J, K, L from the G2 and replace with the M, N, O, P. Now the Groups
 
G1:
1
2
3
4
5
6
A
B
C
D
E
F
 
G2:
7
8
9
10
11
12
G
H
M
N
O
P
 
Keep a side
I
J
K
L
 
Weigh the G1(A, B, C, D, E, F) and G2 (G, H, M, N, O, P)
 
​2.1 Case: G1(A, B, C, D, E, F) ^ G2 (G, H, M, N, O, P)

2.1.a: G1(A, B, C, D, E, F) = G2 (G, H, M, N, O, P) then we know the defective ball is in group G3 (I, J, K, L). to find out the defective one weigh (N, O, P) with (I, J, K).
 
​ (N, O, P) ^ (I, J, K)

​​2.1.a.1: (N, O, P) = (I, J, K) then the defective ball is L.
​​2.1.a.2: (N, O, P) > (I, J, K) then the defective ball is in (I, J, K)
​​​ then weigh I & J.
​​​​If I = J then the defective ball is K.
​​​​If I > J then the defective ball is J.
​​​​If I < J then the defective ball is I.
2.1.a.3: (N, O, P) < (I, J, K) then the defective ball is in (I, J, K)
​​​ then weigh I & J.
​​​​If I = J then the defective ball is K.
​​​​If I > J then the defective ball is I.
​​​​If I < J then the defective ball is J.
 
2.1.b: G1(A, B, C, D, E, F) > G2 (G, H, M, N, O, P) then we know the defective ball is in group G1 (A, B, C, D, E, F) or G2 (G, H) and (I, J, K, L) are non-defective. to find out the defective one weigh (A, B, C) with (D, E, F).
 
​  (A, B, C) ^ (D, E, F)

2.1.b.1: (A, B, C) = (D, E, F) then the defective ball is either G or H. Weigh G and H.  if G < H then the defective ball is G. or G > H then the defective ball is H.
 
2.1.b.2: (A, B, C) > (D, E, F) then the defective ball is in A, B, C. to find out the defective ball weigh A and B
 
​Weigh A ^ B
​​2.1.b.2.a: if A = B then the defective ball is C.
2.1.b.2.b: if A > B then the defective ball is A. ( because from step 2.1.b we know the defective ball is heavier.)
​​​​2.1.b.2.b: if A < B then the defective ball is B.
​​
2.1.b.3: (A, B, C) < (D, E, F) then the defective ball is in D, E, F. to find out the defective ball weigh D and E
 
​Weigh D ^ E
​​2.1.b.2.a: if D = E then the defective ball is F.
2.1.b.2.b: if D > E then the defective ball is D.
​​​​2.1.b.2.b: if D < E then the defective ball is E.
 
 
2.1.c: G1(A, B, C, D, E, F) < G2 (G, H, M, N, O, P) then we know the defective ball is in group G1 (A, B, C, D, E, F) or G2 (G, H) and (I, J, K, L) are non-defective. to find out the defective one weigh (A, B, C) with (D, E, F).
 
​​​​(A, B, C) ^ (D, E, F)

2.1.c.1: (A, B, C) = (D, E, F) then the defective ball is either G or H. Weigh G and H.  if G < H then the defective ball is G. or G > H then the defective ball is H.
 
2.1.c.2: (A, B, C) < (D, E, F) then the defective ball is in A, B, C. to find out the defective ball weigh A and B
 
​Weigh A ^ B
​​2.1.c.2.a: if A = B then the defective ball is C.
2.1.c.2.b: if A > B then the defective ball is B. (because from step 2.1.c we know the defective ball has less weight.)
​​​​2.1.c.2.b: if A < B then the defective ball is A.
​​
2.1.c.3: (A, B, C) > (D, E, F) then the defective ball is in D, E, F. to find out the defective ball weigh D and E
 
​​Weigh D ^ E
​​2.1.b.2.a: if D = E then the defective ball is F.
2.1.b.2.b: if D > E then the defective ball is E.
​​​​2.1.b.2.b: if D < E then the defective ball is D.
Have to backup @ozo 's feedback:

You make three measurements with three results each.

So your decision tree has exactly 3 ** 3 = 27 branches, which cannot allow you to distinguish the space of 32 (16x2) existing options.

I'd say the original poster has been given a task without an answer / a task, that can be answered in some cases, but not in all.



Comment:
Thinking a little more:
I start contradicting myself again:

we have 32 (16x2) scenarios
we have a decision tree with 27 results
there might be a solution if we manage to group some cases correctly yogether.

So with 3 measurements we might be able to identify which ball is heavier or lighter.
we will definitely not be able to identify for all cases which ball has a different weight and know at the same time whether it is lighter or heavier.

We have 32 distinguishable events, but we just want to group them into 16 different events (the ball, that has a different weight)

Trying to write a small script trying out some options.

My approach is to code something that finds the fastest solution for n balls with all the information discovered so far.
( which balls are normal, which balls might be normal or heavier, which balls might be normal or lighter, whether the other ball is lighter or heavier or stillunknown)

Trying to get the code working for small n's first and then see how to extend it for bigger n's.
At the moment working for 7 balls with weighing 3 times (still missing some elimination logic)
Keep you updated if I have more time this week.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.