i can’t figure out cubic minefield i can’t figure out 1 line of code .
What is your current code?
Look at the first function:
def mult(number, times):
total = 0 # have not multiplied yet
while times > 0: # while you have not yet multiplied the number by the total amount of times
total += number # because multiplication is just repeated addition
times -= 1 # you've added the number one time, so subtract one from the number of times because it's already done
return total # returns the product
Now look at your second function and answer the key questions I added to the code:
def power(number, exponent):
total = 1 # because exponents are repeated multiplication, you need to start with 1 unlike the first function, or else you just multiply by 0 over and over
# You have not yet multiplied the number by itself for x (exponent) times. What do you do WHILE that is true?
# Exponents are repeated multiplication. Look at the first function again. In there, you add and assign the number to the total. (For example, the total is 0 and the number is 3, so adding and assigning 3 to 0 will get you 3. Repeating the process will just keep adding 3 to the total, whatever it may be now.) Now do the same thing, but with multiplication instead of addition.
# You have now successfully multiplied the number by itself once. Now make sure that you don't go looping forever by subtracting and assigning 1 to the exponent.
return total # You are done calculating the answer! :D
Sorry for the long comments, but hope this helps!
4 Likes
i passed the level! thanks!
2 Likes
if you have good gear and over 1000 hp you can walk onto one mine and walk around its easy.