The Answer: Using a scale and 4 weights measure an integer load in the range of 1 to 40


TI got this problem from mathproblems.info #68. Their answer is to use weights 1,3,9 and 27 to assemble the weighting. So an odd value approach, which measures any of the loads directly.

	1        = 1
	2+1      = 3
	3        = 3
	4        = 3+1
	5+3+1    = 9
	6+3      = 9
	7+3      = 9+1
	8+1      = 9
	9        = 9
	10       = 9+1
	11+1     = 9+3
	12       = 3+9
	13       = 1+3+9
	14+9+3+1 = 27
	15+9+3   = 27
	16+9+3   = 1+27
	17+9+1   = 27
	18+9     = 27
	19+9     = 1+27
	20+9+1   = 3+27
	21+9     = 3+27
	22+9     = 1+3+27
	23+3+1   = 27
	24+3     = 27
	25+3     = 27+1
	26+1     = 27
	27       = 27
	28       = 3+27
	29+1     = 3+27
	30       = 3+27
	31       = 1+3+27
	32+3+1   = 9+27
	33+3     = 9+27
	34+3     = 1+9+27
	35+1     = 9+27
	36+1     = 3+9+27
	37       = 3+9+27
	38+1     = 3+9+27
	39       = 3+9+27
	40       = 1+3+9+27
      

I started down an odd value approach when I realized that if you do an "over-under" approach you only need to test half the numbers. If you have to search for the target weight, and do not have other clues as to its weight, then I think worst case it would be faster to tree search with the solution I suggested.

What I am calling an "over-under" approach is basically the observation that if we have a sequence of integer weights A, B,and C we only need weights A and C to measure the range with a scale. We can measure A and C directly, and measure B as greater than A and less than C in two comparisons.

So an even solution with this approach is to us 2,6,12, and 20 to measure the even numbers from 2-40 and then use an "over-under" approach to measure the odd numbers in that range.

	2    =  2
	4+2  =  6
	6    =  6
	8+6  = 12+2
	10+2 = 12
	12   = 12
	14   = 12+2
	16+2 = 12+6
	18   = 12+6
	20   = 20     
	22   = 20+2
	24+2 = 20+6
	26   = 20+6
	28   = 20+6+2
	30+2 = 20+12
	32   = 20+12
	34   = 20+12+2
	36+2 = 20+12+6
	38   = 20+12+6
	40   =  2+6+12+20
      


Email -- joeboy(at)hhhh.org
Back to my home page.