[Solved] Balancing three parameters, so that when one of them changes, the amount does not change


class Param3:

    MAX = 300

    a = 100
    b = 100
    c = 100
    
    def __init__(self, a, b):
        self.a = a
        self.b = b
        self.c = MAX-a-b
        
    def add_A(val):
        # Limitation
        if a+val > MAX:
            val = MAX-a
            print("A > MAX, must be <=")
        elif a+val < 0:
            val = -a
            print("A < 0, must be >=")
        
        a += val
        var coef = b/(b+c)
        b -= val*coef
        c = MAX - a - b

2

solved Balancing three parameters, so that when one of them changes, the amount does not change