Proof of coin and bag problem

319 Views Asked by At

There are 5 bags labeled 1 to 5. All the coins in a given bag have the same weight. Some bags have coins of weight 10 gm, others have coins of weight 11 gm. I pick 1, 2, 4, 8, 16 coins respectively from bags 1 to 5. Their total weight comes out to 323 gm. Identify the bags with 11 coins.

I can solve the problem by using the fact that sum of odd number and even number is odd number

$$x_1+2x_2+4x_3+8x_4+16x_5=323$$ $$odd+even=odd$$ hence $$x1=11$$ $$2x_2+4x_3+8x_4+16x_5=323-11=312$$ dividing by 2

$$x_2+2x_3+4x_4+8x_5=312/2=156$$ $$even + even=even$$ hence $$x2=10$$ similarly continuing ,will get all weights of coin

I found this method very randomly.

I don't have logical reason for dividing by 2 step after each iteration?

is there any better method? what is the reasoning behind this method? is there any recursion happening? how can we prove that this method work?

1

There are 1 best solutions below

3
On BEST ANSWER

First find out how many of the 31 coins (1 + 2 + 4 + 8 + 16) weigh 11 gm. You will find there are 13 of them. Then think of how you can write 13 as a sum of powers of 2 - this is "writing 13 in base 2". Answer, 8 + 4 + 1. So the coins that came from bags 1, 2 and 4 weigh 11 gm each, and the others 10 gm each.