[Solved] Zig zag and zoom help (python)


#1
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:
        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 = 20 + 3 * mod9(time)
    x = 10 + time
    hero.moveXY(x, y)

it says illegal expression for augmented assignment


#2

you can’t change the value of a number.


#3

what do you mean? by you can’t change the value of a number?


#4

So you’ll have to do n=9-n


#5

thanks fro the help I got the error away but the third zig zag does not work


#6

Do the same for

n -=15
and make it
n=n-15


#7

Mod15 is supposed to be the other way. instead of n-=15 it should be n=15-n


#8

tried but the hero stops after the first zig zag now


#9

wait I change again but now it trys to escape but fails


#10

Can i see your equipment please?


#11

And also, don’t change the first def mod15, for mod9, it is supposed to be n-=9 not 9-=n


#12

@Chaboi_3000 mod 15 actually is n -= 15, not n = 15 - n.

Take 22 as an example. its mod 15 should be 7. However if you use n = 15-n, it will be -7, which doesn’t make sense.


#13

IK that, see my last post dude.


#14

@Torazo_TOKUDA did you beat the level yet?


#15

No, not yet. I think


#16

I’m sorry but I’m not on a apple computer so I can’t take screenshot.
but my health is 918
and my attack is the runesword


#17

now it says the code is very slow or a infinite loop


#18

oh by the way here is my code:

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

# Don't change the following code:
while True:
    time = hero.time
    if time < 30:

        y = 10 + 3 * mod15(time)
    else:
        y = 20 + 3 * mod9(time)
    x = 10 + time
    hero.moveXY(x, y)

the max is 35.7 sec


#19

Do the same that you did with mod 15: n-=9 instead of n=9-n


#20

this 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 = 20 + 3 * mod9(time)
    x = 10 + time
    hero.moveXY(x, y)

It trys to dodge the arrow but fails