Dont Rush be quiet: Solved without doing anything

Aloha,

I opened https://codecombat.com/play/level/dont-rush-be-quiet and passed the level without doing anything.
I sat there for 10 min and thought about how to solve this, till I pressed the Play-Button.
Here is the code how I found it.

// Dodge the cannons and collect 8 gems.
// Watch out, cannons are ready to fire!
// Move slow along a special pattern to confuse them.

// This function returns a value from 0 to 30:
function mod30(n) {
    if (n >= 30) {
        return n - 30;
    } else {
        return n;
    }
}

// This function should return a value from 0 to 40:
function mod40(n) {
    // Use an if-statement to return the correct value.
    if (n >= 40) {
        return n - 40;
    } else {
        return n;
    }
}

// You dont need to change the following code:
while (true) {
    var time = hero.now();
    var x = mod30(time) + 25;
    var y = mod40(time) + 10;
    hero.moveXY(x, y);
}

Best regards

1 Like

Hi! Thank you. Fixed.

1 Like

um whenever my hero goes up and stuff
the randomizer makes it so at the end my hero dies no matter what so i cant fix it heres my code

# Dodge the cannons and collect 8 gems.
# Watch out, cannons are ready to fire!
# Move slow along a special pattern to confuse them.

# This function returns a value from 0 to 30 (0 <= n < 30)
def mod30(n):
    if n >= 30:
        return n - 30
    else:
        return n

# This function should return a value from 0 to 40 (0 <= n < 40)
def mod40(n):
    # Use an if-statement to return the correct value.
    if n >= 40:
        return n + 40
    else:
        return n

# You don't need to change the following code:
while True:
    time = hero.time
    x = mod30(time) + 25
    y = mod40(time) + 10
    hero.moveXY(x, y)
    

nvr mind i fixed it i realised the return n was + instead of -