Smallest Set of Weights for Two-Pan Balance

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

Let this set of scales 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 $$, place weight $3^k$ in neither pan.

This will make the scales balance.

Also see

 * Smallest Set of Weights for One-Pan Balance