[SOLVED] Cubic Minefield help

:grin: the ducky tries to be helpful when it sees something it doesn’t recognise, and it suggests what it thinks might be right.

In this case, it’s isn’t right, so ignore it. You want ‘exponent’ in there instead.

like this?

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

# This function returns the number to the exponent power.
def power(number, exponent):
    total = 1 
    # Complete the function.
    while exponent < 1:
        total -= number
        exponent += 2
    return total

# Don't change the following code
# You can find coefficients for the equation on the tower
tower = hero.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

def power(number, exponent):
    total = 1
    # Complete the function.
    while exponent > 0:
        total *= number # Since this is exponent, you MULTIPLY AND ASSIGN
        exponent -= 1
    return total

Try it now, it should work

2 Likes

no, it does not sry. I don’t do anything.

How??? it worked for me???

@1styoutuber, can you post your code (again!)? It helps if we can check the indentations/spelling mistakes each time.

1 Like

nevermind just removed the ring of speed and it work sry!

2 Likes

Im confused by this level:

# Walk through the minefield

# This function returns the number multiplied by the times
def mult(number, times):
    total = 0
    while times > 0:
        total += number
        times -= 1
    return total

# This function returns the number to the exponent power.
def power(number, exponent):
    total = 1
    # Complete the function.
    while hero.time > 1:
        total += number
        times -= 2
    return total

# Don't change the following code
# You can find coefficients for the equation on the tower
tower = hero.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

What are you confused by

I can’t get “def power” to work…

explain please

I succeeded with the code through trial and error but don’t understand it- is this problematic at this stage?

I also need help… here ism code:

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

# This function returns the number to the exponent power.
def power(number, exponent):
    total = 1
    # Complete the function.
    times -= 1
    return total

# Don't change the following code
# You can find coefficients for the equation on the tower
tower = hero.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

the duck says “try hero.time” but I don’t know why it is saying that…

Complete the “power” function

1 Like