Cubic Minefield and complete confusion of cubic equations

Alright so I managed somehow to get past the level itself, but I went back into the level after beating it to see all the code that was pre-written. I studied up via the wiki, and a few other sources as to what and how it works (cubic equations that is), and I feel quite lost.

What I think I understand so far is:
the equation looks something like “[b] a^x3 + b^x2 + c^x1 + d = 0[b]”, that “a” can’t be 0 but “b, c, or/and d” could be. I also get that in cubic equations there is use of quadratic equations which I think I’m getting the grasp of quadratic equations, I’ve got the formula down and such just shaky on it yet is all. Lastly, that there are three answers to all cubic equations, which have real roots, and complex roots (which complex roots come in pairs).

The other thing I’m struggling to understand is how its being used in code.

def mult(number, times):
    total = 0
    while times > 0:
        total += number
        times -= 1
    return total

is the example code given to help get an idea for what to do on power from what I understand. Is “mult” defining " * "?

# Don't change the follow code
# You can find coefficients for the equation on the tower
tower = self.findFriends()[0]
a = tower.a
b = tower.b
c = tower.c
d = tower.d
x = hero.pos.x

while True:
    # To find the path use a cubic equation
    y = a * power(x, 3) + b * power(x, 2) + c * power(x, 1) + d * power(x, 0)
    hero.moveXY(x, y)
    x = x + 5

is the pre-written code for what I understand the coefficient’s a,b,c, and d. Using “x” for hero.pos.x so that it is current pos + 5 = x in the code…i think. Is that correct? I was also curious about the coefficient the tower gives, how would I know which numbers where which accordingly based on a character or object?

Last question I have about this level/cubic equations for the moment at least. Could someone explain the math of it all? (or to be put in better words “How does the “def mult” and “def power” able to work inside of the equation?”)

Sorry it’s kind of long. I honestly didn’t want to have to ask for too much help, but I really want to understand all of this in case I either come across it again and need to use it or I see an opportunity to do so and want to. Any help at all is greatly appreciated.

Yep, it’s an example to help you write power function.

You can check them with say or debug (if you have ProgrammaticonV)