Infinite loop for "Zig Zag and Zoom?"


#1

I’m trying to get onto the Zig Zag and Zoom in the Sarven Desert, but every time I try to get on, it says that there was an infinite loop detected.


#2

there should be an option for you to click “comment out my code” or something like that. Just click it and then repair the infinite loop.


#3

It puts in a return, but then that messes up my code and makes my hero not do anything, causing him to be killed.


#4

There must be a problem with your code. Please copy it from the game and post it here using the </> button or a screen shot of it so we can help you. Thanks.


#5

Okay. Here you go.
return #Commented out to stop infinite loop.

hero.findNearestEnemy() #Commented out to stop infinite loop.

Escape from Death Valley!

Move by with a zigzag pattern using real modulo functions.

This function returns a value from 0 to 15:

def mod15(n):
while n >= 15:
n -= 15
return n

This function should return a value from 0 to 9:

def mod9(n):
# While n is greater or equal to 9, subtract 9 from n:
while n > 9 or n == 9:

    9 - n
return n

#6

Sorry, I did something wrong while copying it. Here is the real one.
return #Commented out to stop infinite loop.

Escape from Death Valley!

Move by with a zigzag pattern using real modulo functions.

This function returns a value from 0 to 15:

def mod15(n):
while n >= 15:
n -= 15
return n

This function should return a value from 0 to 9:

def mod9(n):
# While n is greater or equal to 9, subtract 9 from n:
while n > 9 or n == 9:

    9 - n
return n

Don’t change the following code:

while True:
time = hero.time
if time < 30:
y = 10 + 3 * mod15(time)
else:
y = 10 + 3 * mod9(time)
x = 10 + time
hero.moveXY(x, y)


#7

I broke out of my infinite loop, but I am still having trouble. Please help me! Here is My code now.
def mod15(n):
while n >= 15:
n -= 15
return n

This function should return a value from 0 to 9:

def mod9(n):
# While n is greater or equal to 9, subtract 9 from n:
while n >= 9:

    n -= 9
return n

Don’t change the following code:

while True:
time = hero.time
if time < 30:
y = 10 + 3 * mod15(time)
else:
y = 10 + 3 * mod9(time)
x = 10 + time
hero.moveXY(x, y)


#8

def mod15(n):
while n >= 15:
n -= 15
return n

This function should return a value from 0 to 9:

def mod9(n):
# While n is greater or equal to 9, subtract 9 from n:
while n >= 9:
n = n - 9
return n

Don’t change the following code:

while True:
time = hero.time
if time < 30:
y = 10 + 3 * mod15(time)
else:
y = 10 + 3 * mod9(time)
x = 10 + time
hero.moveXY(x, y)


#9


#10
def mod15(n):
    while n >= 15:
        n -= 15
    return n

# This function should return a value from 0 to 9:
def mod9(n):
    # While n is greater or equal to 9, subtract 9 from n:
    while n >= 9:
        n = n - 9
    return n 

# Don't change the following code:
while True:
    time = hero.time
    if time < 30:
        y = 10 + 3 * mod15(time)
    else:
        y = 10 + 3 * mod9(time)
    x = 10 + time
    hero.moveXY(x, y)

#11

You have a computational format problem. Compare the code for function mod15 to the code for function mod9. mod15 is correct, mod9 is not.

Also, did you change the code below the line where it says,

 # Don't change the following code:

The reason I ask is because the computation in the else conditional,

y = 10 + 3 * mod9(time)

should be:

y = 20 + 3 * mod9(time)

#12

thank you for helping me out. it worked


#13

LOL this level need edits. I beat this level in 2 lines of code. See Attached.


#14

Nice. Why bother with loops, conditions, variables, and functions when you can get away with just writing two simple lines of code. LOL.


#15

They should make the arrows deal 9001 dmg (like the plasma balls)