There is a bag of rice given to us and we need to get 1 Kilogram of rice from it but we have only a common balance with two pans, some vessels and a 1 gm weight.
What is the least number of weighs we need to carry out to get 1 Kg of rice?
1) ‘vs.’ below separates the two pans A and B of the common balance and the two pans weigh equal in each weigh.
2) Rice of certain weight obtained in a step is used in the next steps along to get rice of more weight.
Assume the left pan is A and right pan is B.
And in each weighs pan A contains certain reference weight and pan B is filled with enough rice from the bag to balance it.
(In some cases pan B may have the 1 gm weight also in addition to the rice to be taken from the bag while pan A may have just rice of some known weight as in 7th weigh.)
The 10 weighs are explained below:
1st weigh: (1 gm weight) vs. (1 gm rice)
(1 gm rice obtained in the 1st weigh is moved to Pan A below)
2nd weigh: (1 gm weight + 1 gm rice) vs. (2 gm rice)
(The 2 gm rice obtained in the 2nd weigh is combined with 1 gm rice existing in Pan A for the next weigh below)
3rd weigh: (1 gm weight + 3 gm rice) vs. (4 gm rice)
(The 4 gm rice obtained in the 3rd weigh is combined with 3 gm rice existing in Pan A for the next weigh)
4th weigh: (1 gm weight + 7 gm rice) vs. (8 gm rice)
(The 8 gm rice obtained in the 4th weigh is combined with 7 gm rice existing in Pan A for the next weigh)
5th weigh: (1 gm weight + 15 gm rice) vs. (16 gm rice)
(The 16 gm rice obtained in the 5th weigh is combined with 15 gm rice existing in Pan A for the next weigh)
6th weigh: (1 gm weight + 31 gm rice) vs. (32 gm rice)
(The 32 gm rice obtained in the 6th weigh and existing 31 gm rice in Pan A above are together put in Pan-A and 1 gm weight is put in the Pan-B for the next weigh, to get 62 gm rice from the bag!)
7th weigh: (32 gm rice + 31 gm rice) vs. (1 gm weight + 62 gm rice)
(The 63 gm rice in Pan-A above and 62 gm rice in Pan-B above are together put in Pan-A for the next weigh below)
8th weigh: (125 gm rice) vs. (125 gm rice)
(The 125 gm rice obtained in the 8th weigh is combined with the 125 gm rice existing in Pan A for the next weigh)
9th weigh: (250 gm rice) vs. (250 gm rice)
(The 250 gm rice obtained in the 9th weigh is combined with the 250 gm rice existing in Pan A for the next weigh)
10th weigh: (500 gm rice) vs. (500 gm rice)
Now combine both the contents of Pan-A and Pan-B to get 1 Kg of rice.
Explanation of the strategy:
As we have only a 2-pan common balance and 1 gm weight to start off, we can only grow at a rate of 2n and to reach 1000 gm from 1 gm, we need at least 10 steps or 10 weighs. (Imagine a three pan balance, we can grow approximately tripling the weight of the rice! Similarly for an n-pan balance where n>3)
But if we reach 1024 gm (210), we need to remove 24 gm of rice which needs extra weighs which we are not interested in.
So, we realize that 1000/2 =500; 500/2 = 125; 125/2 = 62.5 and 62.5/2 = 31.25, and so on.
The first small whole number in the above series is 125. That can be obtained by 63+62 and we know we have a 1 gm weight and hence when we go on approximately doubling the weight of rice, (1 gm weight + 31 gm of rice) vs. (32 gm rice) is obtainable. Put this 32 gm in vessel V1. So, to get 125 gm rice, we can weigh by keeping that 31 gm of rice in left pan A and get 31 gm rice in right pan B and keep that new 31 gm in a vessel-V2 and again repeat the same to get 31 gm in pan B. Now combine pan-A+ pan-B+ vessel-V2 + vessel-V1 to get (31+31+31+32) 125 gm. If you observe, in these previous weighs, we are not doubling the rice we have. So the extra vessels are given in the question only to detract the problem solver.
Precisely here lies the trick. If we don’t grow double at any step, we are not going to achieve minimum weighs to get 1 Kg of rice.
So, we have to get to 125 gm quickly than this. One way as you can contemplate is to just double (or approximately double) in each step to get to the minimum required weighs. Hence, once (1 gm weight + 31 gm of rice) vs. (32 gm rice) is obtained, we double the rice approximately than what we have by keeping 63 gm in pan A and keep 1 gm weight in pan B and thus get 62 gm of rice which is 4 less than 63*2 gm. And then combine all the rice we have, we actually have 125 gm rice which we needed in the first place.
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses
are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!