[SOLVED] Cubic Minefield help

It is not a code problem just a math issue I have no clue what this level really wants me to do.

# This function returns the number to the exponent power.
def power(number, exponent):
    total = 1
    # Complete the function. It must return the cube of the base
    
    return total

I am so stumped.

We provide a similar function for multiplication above the empty power function which should guide you into making the power function!

On a side note, shouldn’t power return not just the cube of the base as stated in the comment, but the given exponent of the base?

Sorry, it was the wrong comment (rudiment). Fixed.

1 Like

I’m stuck too. Can you help?

I think it’s better for you to play levels in campaign one by one and learn. Adventurer levels are usually for experienced players.

@Bryukh never mind i solved it… old post

i am stuck at it too. can you help me to pass it?

what is wrong? can you tell me?

Please post your code so we can help :wink:

Sorry, my telepathic abilities are limited. Could you give more information?

1 Like

I have the SAME PROBLEM GETTING PAST THIS LEVEL!
This is my 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 little ducky shows up.

The power() is missing some parts. Take a closer look at the mult() function above. You will want to mimic a lot of the setup, with a minor modification to some words and the math symbol.

To get multiplication you add one number as many times of the other. 5 x 4 = 20
5 + 5 + 5 + 5 = 20

To get exponential power, you don’t add one number by the times of the other, but something else: 2 ^ 4 = 16

I can’t pass, can you help?

This is my code, what is the problem?

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 exponent > 1:
total += number
exponent -= 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

Please format your code.
Instructions are here: How to Post Your Code With Radiant, Harmonious Formatting.

hi, I need help with my code:

# 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



plz help me to improve my skills

while hero.time > 1:

Look at the top bit of code as a guide. This level doesn’t need anything to do with hero.time!

           
while hero.time > 1:
        total += number

Think about what the mathematical function is. For ‘times’, if you say 3 times y you actually mean y + y + y. For the third ‘exponential’ of y you want y x y x y. What function do you need to put in?

        times -= 2

This should be the same as the one in the top bit of code.

but the ducky come and says try hero.time see?