 # [SOLVED] Cubic Minefield help

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 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

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

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

# This function returns the number multiplied by the times

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

# 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

# You can find coefficients for the equation on the tower

tower = hero.findFriends()
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

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

# 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

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

# 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

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

Try it now, it should work

1 Like

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!

1 Like