# Thread: Need help: weights problem

1. ## Need help: weights problem

You are given N weights, the first weighs 1 pound, the second 2 pounds, and so on (the N weight weighs N pounds)ץ
You are given an N-binary-word that's formed by L's and R's and scales.
You need to provide an algorithm of N steps, which in each step puts a weight on on of the scales (the left or the right one), and that in the i-th step the scales will lean left if the i-th letter in the word is L and will lean right if it's R.

for example: if N=3 and the word is LLR then the algorithm should say:
1. put 2 on the left scale
2. put 1 on the right scale (the scales will still lean to the left)
3. put 3 on the right scale

2. ## Re: Need help: weights problem

I have no algorithm more sophisticated than trying the combinations and seeing what happens.
Here are the results for 7 weights that minimize the amount of imbalance in the scale.
Note that negative numbers represent a weight placed in the left pan; positives go on the right.
To get the combinations where the scale tips right first, reverse the signs.

LLLLLLL -7 6 -5 4 1 -3 2
LLLLLLR -6 5 -3 2 1 -4 7
LLLLLRL -5 4 -3 2 1 6 -7
LLLLLRR -6 5 -3 2 -4 7 1
LLLLRLL -5 4 -3 2 7 -6 -1
LLLLRLR -4 3 -2 1 6 -7 5
LLLLRRL -5 4 -1 -2 6 3 -7
LLLLRRR -6 5 -3 2 7 -4 1
LLLRLLL -5 4 -2 6 -7 3 -1
LLLRLLR -4 3 -2 7 -6 -1 5
LLLRLRL -3 2 -1 6 -7 5 -4
LLLRLRR -4 3 -2 6 -7 5 1
LLLRRLL -5 4 -3 6 2 -7 1
LLLRRLR -4 3 -2 5 1 -7 6
LLLRRRL -5 4 -2 6 -1 3 -7
LLLRRRR -6 5 -4 7 2 -3 1
LLRLLLL -5 4 6 -7 1 -3 2
LLRLLLR -4 3 5 -7 1 -2 6
LLRLLRL -2 1 4 -7 3 5 -6
LLRLLRR -4 3 5 -7 1 6 -2
LLRLRLL -3 2 5 -7 6 -4 -1
LLRLRLR -2 1 5 -7 6 -4 3
LLRLRRL -2 1 5 -7 4 3 -6
LLRLRRR -4 3 5 -7 6 -2 1
LLRRLLR -5 4 6 -2 -7 3 -1
LLRRLLR -1 -3 5 4 -7 -2 6
LLRRLRL -1 -2 4 3 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