Monday, September 8, 2014

Find a jar (from multiple jars) having less weight, in one scaling.

The problem statement is that you have n number of jars, from which n-1 jars with 10 marbles each, and 10 gm per marble. But, one jar with 10 marbles with weight 9gm. Now, the problem is to weight only once, and find the jar which has weight 9 gm marbles.

Proposed solution:-
Now, as per the proposed solution,
1) Take one marble from jar one, two marbles from jar two, three marbles from jar three and so on...
2) Weigh the marbles
3) The expected weight from n jars should be !n X 10, but we know that one jar is having 9 gm, marbles so the weight will not come as !n x 10, but will come less that it.
4) find the difference, and the differenced number jar is the culprit. i.e. if difference is m, the mth jar from n jars is the one having marbles of 9 gm.

Lets take an examples, of 3 jars

J1 = 10 marbles (each weight 10 gm)
J2 = 10 marbles (each weight 9 gm)
J3 = 10 marbles (each weight 10 gm)

1) 10 (one marble from jar 1) + 9 + 9 (two marbles from jar 2) + 10 + 10 + 10 (three marbles from jar 3)
2) The weight will be 58
3) Expected weight is 60, but the actual weight is 58
4) Difference is 2, i.e. jar number 2 is the culprit.

lets take another example of 5 jars
J1 = 10 marbles (each weight 10 gm)
J1 = 10 marbles (each weight 10 gm)
J1 = 10 marbles (each weight 10 gm)
J1 = 10 marbles (each weight 9 gm)
J1 = 10 marbles (each weight 10 gm)

Now, lets again execute the theorem, i.e.
10 + (10 + 10) + (10 + 10 + 10) + (9 + 9 + 9 + 9) + (10 + 10 + 10 + 10 + 10)
Expected weight= 150
Actual weight= 146
Difference = 150 - 146 = 4
i.e. Jar number 4 is having 9gm marbles.

Hence Proved !!!

No comments:

Post a Comment