# How to weigh up to 100kg with 5 weights

1) You are a shopkeeper who is selling sugar between 1-100 kg .Now you have to design 5 weights in such a way that any integer weight between 1-100 can be measured in a single attempt ,without using more than 5 weights.You can't repeat weights.

He gave me time like 1 hour to figure it out, and i tried it as hard as i could. But finally i couldn't figure out more than this that weights have to be distributed on both sides of measurement.

Does anybody have some clue as what could be the answer.

• What does it mean, "you can't repeat weights?" No two of these five weights may be the same? And why would that make the problem any easier?
– Kaz
Commented Oct 31, 2013 at 15:02
• And btw, what is a "single attempt"? By a single attempt, I can only have two answers: yes or no, and surely not 100 different answers. Do I miss something?
– yo'
Commented Oct 31, 2013 at 15:10
• Perhaps the "single attempt" aims to check the correctness of a weight claimed for a premeasured amount of sugar? Commented Oct 31, 2013 at 15:33
• Single attempt, as in, you can't measure 1kg of sugar 100 times or even 50kg of sugar twice...you have to balance the scale with 100kg of sugar on it. Commented Oct 31, 2013 at 20:02

Use powers of $3$: $1,3,9,27,81$ can weigh anything up to $121$.

The trick is to place weights on both sides of the pan. Without that, the maximum you can do is with powers of two, and five of those will allow you to go up to $63$. At least if you only consider exact weighings. If you're allowed to infer that the weight is $14$ if it is heavier than $13$ and lighter than $15$ will probably allow you to go a bit higher, and I don't yet see a systematic way of going about this.

$121$ is the maximum you can do with 5 weights. See http://www.uri.edu/artsci/math/clark/mthdl/scale/explore.pdf for necessary and sufficient conditions.

On the other hand, since you can optimally go up to $121$, there is some choice if you only want to go up to $100$. There are 132 sets of weights that work, 15 of them measuring up to exactly $100$, and the lexicographically smallest one is $1,3,7,22,67$.

Further, the proof for sufficiency is constructive. That is, you can figure out an algorithm to tell you which weights go on which side for any of these sets of weights.

• Put $81$ on one scale, the sugar and $1,3,9,27$ on the other. Commented Oct 31, 2013 at 11:12
• Oh I see. Riiight you can put them on both sides Commented Oct 31, 2013 at 11:13
• @self.: No. This can be thought of as an expression of base 3 in a strange way. When counting in base 3 you have for each power of 3 a value of either zero, one or two. With this solution we are doing the same thing effectively but we give them values of one (its on the oposite side to the item being weighed), zero (not on the scales) or minus one (its on the same side as the weight being measured. If you wanted higher powers you'd need multiples of some weights. eg if you always had two of each size then powers of five would work. Powers of four would work as well but be inefficient. Commented Oct 31, 2013 at 13:19
• @Chris: The system is known as balanced ternary. Commented Oct 31, 2013 at 15:39
• Nice. But why powers of three? Commented Oct 31, 2013 at 16:41

If you used $1,2,4,8..$ kg weights, you could measure until $127$ kg only using seven different weights on one side of scale. Because numbers $0-127$ is written with maximum seven digits in base $2$, i.e. $100=1100100_2$. You can use only one side of scale because you only have $0$ and $1$ digits in base $2$.

On the other hand, in base $3$ you have $1,0,2$ and you can use max five digits to represent numbers in $0-100$. But you have to repeat weights if you use just one side of scale due to digit $2$. But you can rewrite a number in base $3$ as substraction of two numbers in the same base which have only digits $0$ and $1$. For example, $7=21_3$, which means you have to use two $3$ kg and one $1$ kg to measure $7$ kg if you only use one side of scale. But since you are not restricted to only one side, you can write $7$ as $101_3-10_3$. You put $101_3=10$ kg to left side, $7$ kg and $10_3=3$ kg to right.

• A simple proof of sufficiency: Write the weight to be measured (W say) as 121 - X. 121 is 11111 in ternary representation. If i-th digit (from right starting from 0) of X is 0, put the weight 3^i in the right arm of the scale. If it is 1, put 3^i in neither arm. If it is 2, put it in the left arm. Let the left and right sums be L and R. It can be easily seen that R - L = W. Not only do R and L contain only 0's and 1's in ternary, they don't contain 1 in the same place (power of 3). Commented Oct 31, 2013 at 18:55
• @SPrasanth that seems a very clever algorithm. Thanks. Commented Oct 31, 2013 at 19:02
• @SPrasanth I didnt get that, can you please elaborate?
Commented May 16, 2016 at 14:01
• @SPrasanth I dont see it working, e.g. for 121=11111 in ternary, according to your logic "If it is 1, put 3^i in neither arm", you wont put any weight in any arm, which is wrong. Or did I misunderstood?
Commented May 17, 2016 at 4:21
• @Tingya I know this is late, but regardless... Step 1 is to write the weight W as 121-X. Then we look at the ternary rep of X. So for W=121, X=0, and all the weights will go in the right arm. Commented Nov 22, 2016 at 4:37

Minimum weight is 1 kg max is 18 kg

You can obtain 25337 combinations

Here is the code

a = 1

Do While a < 100

   b = a + 1
Do While b < 100
c = b + 1
Do While c < 100
d = c + 1
Do While d < 100
e = d + 1
Do While e < 100
total = a + b + c + d + e
If total = 100 Then
counter= counter + 1
Text1.Text = counter
End If
e = e + 1
DoEvents
Loop
d = d + 1
Loop
c = c + 1
Loop
b = b + 1
Loop
a = a + 1
If a > 18 Then
Text2.Text = "THE END"
End If


Loop

• The corrrect limit for a is better 18 and b 19 so on... Commented Nov 1, 2013 at 8:35