Created
September 15, 2015 20:36
-
-
Save D-32/a70005f59801d789479a to your computer and use it in GitHub Desktop.
Level 5 Solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_levelNr = 5; | |
delay = 100; | |
function exec() { | |
// new function -> getX(); and getY(); | |
// use these to check that you don't leave the playing field | |
var check = 9; | |
for (var i = 0; i < 200; i++) { | |
if (getX() == check) { | |
if (check == 9) { | |
check = 0; | |
turnRight(); | |
move(); | |
turnRight(); | |
} else { | |
check = 9; | |
turnLeft(); | |
move(); | |
turnLeft(); | |
} | |
} else { | |
m(); | |
} | |
} | |
} | |
function m() { | |
if (isFacingHole()) { | |
turnRight(); | |
move(); | |
turnLeft(); | |
move(); | |
move(); | |
turnLeft(); | |
move(); | |
turnRight(); | |
} else { | |
move(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment