Smallest Set of Weights for Two-Pan Balance

Classic Problem
Consider a balance for determining the weight of a physical object.

Let this balance be such that weights may be placed in either of the two pans.

What is the smallest set of weights needed to weigh any given integer weight up to a given amount?

Solution
A set of weights up to $3^m$ in the sequence $\sequence {3^n}$:
 * $1, 3, 9, 27, \ldots$

allows one to weigh any given integer weight up to $\dfrac {3^{m + 1} - 1} 2$.

Proof
Place the item to be weighed in the left hand pan of the balance.

Let it weigh $n$.

Let $n$ be expressed in balanced ternary representation.

From Representation of Integers in Balanced Ternary, $n$ can be uniquely so represented.

With $m$ digits, we can count up to $\dfrac {3^{m + 1} - 1} 2$.

We use the balanced ternary representation to model how to place the weights.

Let the digits of $n$ in such a representation be numbered $0, 1, \ldots, m$ from the to the.

The $k$th digit represents the weight which weighs $3^k$.

When the $k$th digit is $1$, place weight $3^k$ in the right hand pan.

When the $k$th digit is $\underline 1$, place weight $3^k$ in the left hand pan.

When the $k$th digit is $0$, place weight $3^k$ in neither pan.

This will make the balance level.

Also see

 * Smallest Set of Weights for One-Pan Balance