Skip to content

Instantly share code, notes, and snippets.

@itsJarrett
Created September 21, 2016 13:22
Show Gist options
  • Save itsJarrett/39656409f7fcfb5f05f38ba6f40b8ba4 to your computer and use it in GitHub Desktop.
Save itsJarrett/39656409f7fcfb5f05f38ba6f40b8ba4 to your computer and use it in GitHub Desktop.
Karel Checks
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