Simulating a scale, balancing weight from lists
Write functions. Make this a balance_scale function, that returns the minimum.
Your variable names are pretty poor, single letter variable names leave people guessing at what they mean.
You should change cc = cc = ... to just one assignment.




Since you can use a maximum of two spare weights the solution can be a lot simpler than you've produced.


\$W_1\$ is the smaller weight in weights and \$W_2\$ is the larger.
If \$W_1 = W_2\$ then you return an empty list.
We can determine what weight is needed when only one weight can be used.

\$S = W_2 - W_1\$

Therefore if \$S\$ is in spare_weights then we can return \$S\$.
For each \$S_1\$ in spare_weights we can determine the weight needed, \$S_2\$.

\$S_2 = |W_2 - W_1 - S_1|\$

We take the absolute as this weight can be on either side of the scale. If the non-absolute value of \$S_2\$ is positive then we add it to \$W_1 + S_1\$ if it's negative then we add it to \$W_2\$.


If we add \$0\$ twice to spare_weights, then we can see that (4), (3) and (2) are all roughly the same equation.

We don't need to check if \$S_1\$ and \$S_2\$ both exist in spare_weights, as the only time they are the same is if \$W_1 = W_2\$, and so they would both be 0. We however have to assign \$S_1\$ to 0 first.

def balance_scale(scale, spares):
    w1, w2 = sorted(scale)
    spare_set = set(spares) | {0}
    for s1 in [0] + spares:
        s2 = abs(w2 - w1 - s1)
        if s2 in spare_set:
            return [i for i in [s1, s2] if i]
    return None


print(balance_scale([4, 3], [1, 2, 7, 7]))


[1]