# Weights and Measures

By | 2011-03-20

You have a set of balance scales and some weights. You need to be able to measure every whole number weight from 1 to 40 kilograms of (say) flour. What is the smallest number of weights you need and what are their values?

The first trick is of course that you can put weights on either side, so you have to notice that you don’t necessarily need to be able to sum to every value, you can subtract as well. If we put the flour on the right hand side, then anything we put on the left adds to the balance, and anything we put on the right subtracts from the balance. For example, if we had two weights, 1kg and 3kg we could make.

• 1kg
• 3kg
• 1kg + 3kg = 4kg
• 1kg – 3kg = –2kg
• 3kg – 1kg = 2kg

Obviously the negative weight isn’t going to be useful to us, as we will never be called upon to weigh –2kg of flour.

So, each weight can be in one of three places:

• The same side as the flour
• Not the same side as the flour
• Not on the scale at all

We’ll call the side the flour is on the “minus-side” (since, from the point of view of the plus side, it effectively lowers the weight of the plus side) and the other side the “plus-side”.

$Y$

and

$Z$

, here are all possible configurations:

• $0$
• $+Y–0$
• $+Z–0$
• $0–Y$
• $0–Z$
• $Y–Z$
• $Z–Y$
• $+Y+Z–0$
• $0–Y–Z$

There are nine configurations, which shouldn’t surprise us. Two weights each in any of three places, is

$3×3=9$

Let’s also recall that we can’t measure 0kg and we can’t measure negative weights of flour (since they cannot exist), therefore our equation for real combinations measurable with

$m$

weights is

$N\left(m\right)=\frac{\left({3}^{m}–1\right)}{2}$

We can therefore be certain then that two weights isn’t sufficient to measure 40 different weights of flour. Similarly, three weights would be

$3×3×3=27$

$N\left(3\right)=\frac{\left(27–1\right)}{2}=13$

Thirteen weights would be insufficient to distinguish between 40 different inputs.

$3×3×3×3=81$

$N\left(4\right)=\frac{\left(81–1\right)}{2}=40$

Perfect! What we want is possible. Let’s list all the configurations of four weights (zero and negatives included). In the following table, “0” means not on the scales, “-” means on the same side as the flour and “+” means not on the same side as the flour (the eagle eyed amongst you will notice that this is simply a base–3 count):

``````W   X   Y   Z       W   X   Y   Z       W   X   Y   Z
-------------       -------------       -------------
+   +   +   +       -   +   +   +       0   +   +   +
+   +   +   -       -   +   +   -       0   +   +   -
+   +   +   0       -   +   +   0       0   +   +   0
+   +   -   +       -   +   -   +       0   +   -   +
+   +   -   -       -   +   -   -       0   +   -   -
+   +   -   0       -   +   -   0       0   +   -   0
+   +   0   +       -   +   0   +       0   +   0   +
+   +   0   -       -   +   0   -       0   +   0   -
+   +   0   0       -   +   0   0       0   +   0   0
+   -   +   +       -   -   +   +       0   -   +   +
+   -   +   -       -   -   +   -       0   -   +   -
+   -   +   0       -   -   +   0       0   -   +   0
+   -   -   +       -   -   -   +       0   -   -   +
+   -   -   -       -   -   -   -       0   -   -   -
+   -   -   0       -   -   -   0       0   -   -   0
+   -   0   +       -   -   0   +       0   -   0   +
+   -   0   -       -   -   0   -       0   -   0   -
+   -   0   0       -   -   0   0       0   -   0   0
+   0   +   +       -   0   +   +       0   0   +   +
+   0   +   -       -   0   +   -       0   0   +   -
+   0   +   0       -   0   +   0       0   0   +   0
+   0   -   +       -   0   -   +       0   0   -   +
+   0   -   -       -   0   -   -       0   0   -   -
+   0   -   0       -   0   -   0       0   0   -   0
+   0   0   +       -   0   0   +       0   0   0   +
+   0   0   -       -   0   0   -       0   0   0   -
+   0   0   0       -   0   0   0       0   0   0   0
``````

Let us (for our own convenience) assume that

$W$

is the heaviest, running to

$Z$

, the lightest. Such that

$W\ge X\ge Y\ge Z$

We know that the most we can put on one side is all the weights. Therefore all of our weights must add up to some maximum,

$N$

.

$W+X+Y+Z=N$

The second heaviest weight we are asked to weigh is

$N–1$

, and the least we can take off is the smallest weight,

$Z$

, therefore

$W+X+Y=N–1$

Therefore

$Z=1$

(subtract these two equations). Which then enables us to measure

$N–2$

by putting

$Z$

on the minus-side.

Now we must measure

$N–3$

. The least we can do is replace

$Z$

on the plus-side and remove

$Y$

.

$W+X+Z=N–3$

Therefore

$Y=3$

. Which then enables us to measure

$\left(N–4\right)$

,

$\left(N–5\right)$

,

$\left(N–6\right)$

,

$\left(N–7\right)$

, and

$\left(N–8\right)$

. Recapping:

$W+X+Y+Z=N$

$W+X+Y+0=N–1$

$W+X+Y–Z=N–2$

$W+X+0+Z=N–3$

$W+X+0+0=N–4$

$W+X+0–Z=N–5$

$W+X–Y+Z=N–6$

$W+X–Y+0=N–7$

$W+X–Y–Z=N–8$

You should be able to see the pattern from the table evolving now. Each weight is either positive, off, or negative. Which means we get double duty from each one. Taking

$Z$

off lowers the total by 1kg; adding

$Z$

to the negative side lowers the total by another 1kg. So, with

$Z$

we can subtract 0, 1 or 2 from a given point (where

$Z$

is “on”).

$Y$

lets us subtract 0, 3 or 6 from a given point (where

$Y$

is “on”). Combined

$Z$

and

$Y$

lets us subtract 0, 1, 2, 3, 4, 5, 6, 7, or 8 from a given point (where

$Y$

and

$Z$

are “on”).

It’s now pretty simple to carry on. The next smallest change we can make is to remove the second heaviest weight; we want that to give us

$\left(N–9\right)$

:

$W+0+Y+Z=N–9$

Therefore

$X=9$

.

$Y$

and

$Z$

are both “on” so we know that we can subtract another 8 kg from

$\left(N–9\right)$

in sequence, taking us to:

$W+0+Y+0=N–10$

$W+0+Y–Z=N–11$

$W+0+0+Z=N–12$

$W+0+0+0=N–13$

$W+0+0–Z=N–14$

$W+0–Y+Z=N–15$

$W+0–Y+0=N–16$

$W+0–Y–Z=N–17$

Now we have to put X on the minus side, from there we know that

$Y$

and

$Z$

back on will give us the ability to do another 8 kg:

$W–X+Y+Z=N–18$

$\dots$

$W–X–Y–Z=N–26$

That only leaves us with the option of putting

$X$

,

$Y$

and

$Z$

back on, and taking

$W$

off, which we want to give us the next value,

$N–27$

$0+X+Y+Z=N–27$

Subtracting this from the initial equation,

$\left(W+X+Y+Z=N\right)$

:

$W=N–\left(N–27\right)$

$=27$

So,

$W=27$

. Further,

$W$

,

$X$

,

$Y$

and

$Z$

are now known, so we can calculate that

$N=40$

.

We already know that we can position

$X$

,

$Y$

and

$Z$

to subtract up to 26, which is just what we need to get us to 1kg.

$N=40$

$W=27$

$X=9$

$Y=3$

$Z=1$

QED.

Now let’s go even more general. For

$n$

weights, what is the maximum weight of flour we can weigh? What weights do we need?

We’ll plough through this a little faster, first let’s add an additional weight:

$V+W+X+Y+Z=N$

$W$

,

$X$

,

$Y$

and

$Z$

are, their derivation is utterly unchanged by the presence of

$V$

. We run out when we come to:

$V–W–X–Y–Z=N–80$

I know that it’s

$N–80$

as follows:

$V+W+X+Y+Z=N$

(eq1)

$W+X+Y+Z=40$

(eq2)

$V–W–X–Y–Z=N–80$

(eq1)-

$2×$

(eq2)

As before, we put all

$W$

,

$X$

,

$Y$

and

$Z$

back on the plus side, and take

$V$

off, and that must be equal to our next integer weight:

$0+W+X+Y+Z=N–81$

As before, we subtract this from our initial equation,

$V+W+X+Y+Z=N$

:

$V+W–W+X–X+Y–Y+Z–Z=N–\left(N–81\right)$

$V=81$

We shouldn’t be surprised; as we said, each weight can be used twice, once when we take it off the plus side, and once when we add it to the minus side. Therefore, the nth weight is the sum of all the previous weights multiplied by two, plus one to get us to the next unknown.

Now we’ll label the

$n$

th weight

$W\left(n\right)$

, with

$n=0$

being the first weight, and

$W\left(0\right)$

equal to one.

$W\left(n\right)$

can be expressed as a function of the sum of all the previous weights:

$W\left(n\right)=\left(\sum _{i=0}^{n–1}W\left(i\right)\right)×2+1$

So:

$W\left(0\right)=1$

$W\left(1\right)=W\left(0\right)×2+1=3$

$W\left(2\right)=\left(W\left(0\right)+W\left(1\right)\right)×2+1=9$

$W\left(3\right)=\left(W\left(0\right)+W\left(1\right)+W\left(2\right)\right)×2+1=27$

$W\left(4\right)=\left(W\left(0\right)+W\left(1\right)+W\left(2\right)+W\left(3\right)\right)×2+1=81$

We should note that the maximum we can weigh with

$n$

weights is the sum of those

$n$

weights, or

$N\left(n\right)=\sum _{i=0}^{n}W\left(i\right)$

Therefore,

$W\left(n\right)=N\left(n–1\right)×2+1$

We should also note that we can get rid of the summation, and simply define

$N\left(n\right)$

in terms of

$N\left(n–1\right)$

:

$N\left(n\right)=N\left(n–1\right)+W\left(n\right)$

Substituting for

$W\left(n\right)$

:

$N\left(n\right)=N\left(n–1\right)+\left(N\left(n–1\right)×2+1\right)$

$=3N\left(n–1\right)+1$

$N\left(0\right)$

we have to define as 1 to match our

$W\left(0\right)$

defined as 1.

$N\left(n\right)=1,4,13,40,121,364,\dots$

$W\left(n\right)=1,3,9,27,81,243,729,\dots$

We’re still defining each term in terms of the previous term, which we needn’t do. We’ve already got an equation for

$N\left(n\right)$

:

$N\left(n\right)=\frac{\left({3}^{n+1}–1\right)}{2}$

This is the very first equation I gave, but adjusted for a start-from-zero

$n$

$m$

. Substituting this into our equation for

$W$

:

$W\left(n\right)=\left(\frac{{3}^{n–1+1}–1}{2}\right)×2+1$

$={3}^{n}$

This shouldn’t be a surprise to us really. The weights are a base–3 counting system, for any base, the nth digit’s multiplier is given by

${B}^{n}$

. If we’d been really clever, we would have recognised this right from the start and just gone straight to the answer. Oh well.