Created
September 21, 2016 13:22
-
-
Save itsJarrett/39656409f7fcfb5f05f38ba6f40b8ba4 to your computer and use it in GitHub Desktop.
Karel Checks
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
public boolean isThereABotOnRtAndOnlyOneBeeperOnLeft() { | |
turnLeft(); | |
move(); | |
if (nextToABeeper()) { | |
pickBeeper(); | |
if (nextToABeeper()) { | |
putBeeper(); | |
turnAround(); | |
move(2); | |
turnLeft(); | |
return false; | |
} | |
putBeeper(); | |
turnAround(); | |
move(2); | |
if (nextToARobot()) { | |
turnAround(); | |
move(); | |
turnRight(); | |
return true; | |
} else { | |
turnAround(); | |
move(); | |
turnRight(); | |
return false; | |
} | |
} else { | |
turnAround(); | |
move(); | |
turnLeft(); | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment