A two sided balance beam works the same way that a one sided balance beam works except that while the object that is being weighed must necessarily be placed on one side of the beam, the fixed weights that come with the set can be place on either side. Thus a 4 and a 5 gram weight can be used to measure either a 9 gram weight by placing both of them on the opposite side from the object to be weighed or they could be used to measure out a 1 gram weight by placing the 4 gram weight on the same side as the object, and the 5 gram weight on the opposite side. Using this scheme, it is possible to weigh any whole number of grams between 1 and 40. What are they?
First let us consider the combinatorial aspects of this problem. With each weight, there are 3 choices: put it on the left side, the right side or leave it off. As a result, there are 34 = 81 different configurations. However, except for the one possibility where all of the weights are left off, if you take all of the weights in a configuration and move them to the opposite side of the balance, you will have a different configuration which will weigh the same weight.
As a result, if we exclude the zero weight, the number of different nonzero weights that can be measured is
so it could be possible to measure all of the weights from 1 to 40 using this system. But we not only have to make sure that all of the numbers between 1 and 40 are provided for, we also have to avoid duplications.
As a result, we can conclude that the weights have to add up to 40. 40 would have to be the largest weight we can measure and we would measure the largest possible weight by putting all of the weights together on one side.
We can then conclude that the smallest weight has to be a 1 gram weight. The only way to measure 39 grams would be to put all of the weights except the lightest one on one side, so the one we left off would have to be a 1 gram weight.
At this point, we proceed like we did in the previous problem. The smallest weight that we cannot measure using the 1 gram weight would be a 2 gram weight. We will not want to use a 2 gram weight to measure this; because then it would be possible to measure 1 gram two different ways: using the 1 gram weight by itself, and putting a 2 gram weight on one side and the one gram weight on the other. So the next weight that we could use would be 3 grams. You could measure 2 grams by putting the 3 gram weight on one side and the one gram weight on the other side with the object that was being weighed. You could use the 3 gram weight to measure 3 grams, and if you put the 3 gram weight and the 1 gram weight together, you could weigh 4 grams. The first number of grams that could not be weighed with these two weights would be a 5 gram weight. But in order to avoid duplication, the next weight would have to be 5 grams more than the 4 grams we already have. So the next weight should be a 9 gram weight. You could then measure the following weights
1 

1 
2 

3  1 
3 

3 
4 

3 + 1 
5 

9  (3 + 1) 
6 

9  3 
7 

(9 + 1)  3 
8 

9  1 
9 

9 
10 

9 + 1 
11 

(9 + 3)  1 
12 

9 + 3 
13 

9 + 3 + 1 
Notice that since the first two weights will measure any weight from 1 to 4 grams, by using the 9 gram weight, you can measure any number of grams from 9  4 = 5 to 9 + 4 = 13 grams. The first weight that can't be measured would be 14 grams. So the next weight should be 13 more than 14 or 27 grams. Since the first three weights enable us to measure any weight from 1 to 13 grams, by using the 27 gram weight, we could measure any number of grams from 27  13 = 14 to 27 + 13 = 40 grams.
Notice that the weights are all powers of 3 in this problem. Moreover, the next weight would be 41 + 40 = 81 which is the next power of 3, and you will find that the next weight that you need will be the next power of 3. Will this generalize?
To get the formula that applies in this case, recall the formula for factoring a difference of powers.
and the related formula for adding a sum of powers
If a = 3 and b = 1 we have
so no matter how many weights there are, the number of possible configurations can be covered by adding up powers of 3. The argument given above can be extended to an inductive proof that this process will generalize.