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?