# Help on Cubic Minefield (Python) \[SOLVED\]

**URL:** <https://discourse.codecombat.com/t/help-on-cubic-minefield-python-solved/20600>\
**Category:** Level Help\
**Created:** [March 23, 2020, 1:38pm UTC](https://discourse.codecombat.com/t/help-on-cubic-minefield-python-solved/20600 "2020-03-23T13:38:31Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![CodingGeek14](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/codinggeek14/32/10566_2.png) [@CodingGeek14](https://discourse.codecombat.com/u/CodingGeek14)\
**Post date:** [March 23, 2020, 1:38pm UTC](https://discourse.codecombat.com/t/help-on-cubic-minefield-python-solved/20600/1 "2020-03-23T13:38:31Z")

</div>

Hi, @dedreous  
I am stuck on Cubic Minefield  
I do not know how to complete the function  
Any help?  
Thanks

---

<div class="post-metadata">

**Author:** ![dedreous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dedreous/32/13849_2.png) [@dedreous](https://discourse.codecombat.com/u/dedreous)\
**Post date:** [March 23, 2020, 2:45pm UTC](https://discourse.codecombat.com/t/help-on-cubic-minefield-python-solved/20600/2 "2020-03-23T14:45:56Z")

</div>

You’ll need to show your code, so we can what/where to help.

---

<div class="post-metadata">

**Author:** ![CodingGeek14](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/codinggeek14/32/10566_2.png) [@CodingGeek14](https://discourse.codecombat.com/u/CodingGeek14)\
**Post date:** [March 23, 2020, 2:52pm UTC](https://discourse.codecombat.com/t/help-on-cubic-minefield-python-solved/20600/3 "2020-03-23T14:52:33Z")

</div>

Sorry, was in a rush, @dedreous  
Anyway, here’s the code:

```python
# 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.
    
    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

```

Also, a snapshot of my situation:

 ![image](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/f/f33155f2ffa47e0fe7bf8ecb365a5c9eff48b259.png)  
The arrow is still there - I do not know how to complete the function.

---

<div class="post-metadata">

**Author:** ![dedreous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dedreous/32/13849_2.png) [@dedreous](https://discourse.codecombat.com/u/dedreous)\
**Post date:** [March 23, 2020, 3:10pm UTC](https://discourse.codecombat.com/t/help-on-cubic-minefield-python-solved/20600/4 "2020-03-23T15:10:40Z")

</div>

Use the first function, def mult() as a template. def power() should look just like it, except that it handles number^exponent, which means number \* number \* number (etc, etc), where exponent is how many times to multiply number by itself.

---

<div class="post-metadata">

**Author:** ![CodingGeek14](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/codinggeek14/32/10566_2.png) [@CodingGeek14](https://discourse.codecombat.com/u/CodingGeek14)\
**Post date:** [March 23, 2020, 3:19pm UTC](https://discourse.codecombat.com/t/help-on-cubic-minefield-python-solved/20600/5 "2020-03-23T15:19:54Z")

</div>

This is what I did:

```python
# 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 > 0:
        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, 75)
    x = x + 5

```

I lost 900 hp but finished the level?:  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/8/882e918c691fc9d31ce2855e62e9f0be5a9da519.png)  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/b/b606cef44b57060cca7aaa15f320fa68574c2ef1.png)

---

<div class="post-metadata">

**Author:** ![dedreous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dedreous/32/13849_2.png) [@dedreous](https://discourse.codecombat.com/u/dedreous)\
**Post date:** [March 23, 2020, 3:23pm UTC](https://discourse.codecombat.com/t/help-on-cubic-minefield-python-solved/20600/6 "2020-03-23T15:23:14Z")

</div>

heh…you should finish with 100% health 😉

In the first function you are adding a number to itself, many times. In the second function, you should MULTIPLY instead.

---

<div class="post-metadata">

**Author:** ![CodingGeek14](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/codinggeek14/32/10566_2.png) [@CodingGeek14](https://discourse.codecombat.com/u/CodingGeek14)\
**Post date:** [March 23, 2020, 3:25pm UTC](https://discourse.codecombat.com/t/help-on-cubic-minefield-python-solved/20600/7 "2020-03-23T15:25:37Z")

</div>

But it worked and I finished the level.  
Creativity or madness and giving up?  
It’s one of the two because I put `hero.moveXY(x, 75)` - which lead to me completing the level and me losing 900hp.

---

<div class="post-metadata">

**Author:** ![Joshua\_Garcia](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/joshua_garcia/32/21728_2.png) [@Joshua\_Garcia](https://discourse.codecombat.com/u/Joshua_Garcia)\
**Post date:** [April 27, 2021, 8:30pm UTC](https://discourse.codecombat.com/t/help-on-cubic-minefield-python-solved/20600/8 "2021-04-27T20:30:51Z")

</div>

my character just keeps running into the bottom of the map. please help!

---

<div class="post-metadata">

**Author:** ![Deadpool198](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/deadpool198/32/16753_2.png) [@Deadpool198](https://discourse.codecombat.com/u/Deadpool198)\
**Post date:** [April 28, 2021, 7:31am UTC](https://discourse.codecombat.com/t/help-on-cubic-minefield-python-solved/20600/9 "2021-04-28T07:31:56Z")

</div>

Please could you post your code.  
Danny
