// Escape from Death Valley!
// The archers firing at you are not your allies! Dodge the arrows!
// Move by with a zigzag pattern using real modulo functions.
// This function returns a value from 0 to 15:
function mod15(n) {
while (n >= 15) {
n -= 15;
}
return n;
}
// This function should return a value from 0 to 9:
function mod9(n) {
while (n >= 9) {
n -= 9;
}
return n;
}
// Don't change the following code:
while (true) {
var time = hero.now();
var x, y;
if (time < 30) {
y = 10 + 3 * mod15(time);
} else {
y = 20 + 3 * mod9(time);
}
x = 10 + time;
hero.moveXY(x, y);
}
That’s my code. It should work but I don’t know why it won’t; it just kills the hero every single time. I even checked for the solution on Github.