6.4.5 Checkerboard Karel Answer | ESSENTIAL · 2025 |

If Karel is placing two beepers side-by-side, your reposition function isn't correctly checking if the last spot of the previous row had a beeper.

fillRow();

function start() putBeeper(); while(leftIsClear()) fillRow(); turnLeft(); move(); turnRight(); 6.4.5 checkerboard karel answer

while (frontIsClear()) placeARow(); repositionForRowChange();

The 6.4.5 Checkerboard Karel problem teaches: If Karel is placing two beepers side-by-side, your

: After completing a row, Karel must move up one row and turn 180 degrees to face the opposite direction. Handling Offsets

function moveUpAndSwitchDirection() turnLeft(); move(); turnLeft(); turnLeft(); turnLeft(); // Effectively turn right. // Now facing opposite direction. // Now facing opposite direction

function fillRow() putBeeper(); while(frontIsClear()) move(); if(frontIsClear()) move(); putBeeper();

Karel starts in the bottom left corner of a world that is any size (but always a rectangle). Karel must fill the entire world with beepers in a checkerboard pattern (alternating spaces). Karel can be facing east at the start, and can end anywhere.

turnAround(); while (frontIsClear()) move();

:

If Karel is placing two beepers side-by-side, your reposition function isn't correctly checking if the last spot of the previous row had a beeper.

fillRow();

function start() putBeeper(); while(leftIsClear()) fillRow(); turnLeft(); move(); turnRight();

while (frontIsClear()) placeARow(); repositionForRowChange();

The 6.4.5 Checkerboard Karel problem teaches:

: After completing a row, Karel must move up one row and turn 180 degrees to face the opposite direction. Handling Offsets

function moveUpAndSwitchDirection() turnLeft(); move(); turnLeft(); turnLeft(); turnLeft(); // Effectively turn right. // Now facing opposite direction.

function fillRow() putBeeper(); while(frontIsClear()) move(); if(frontIsClear()) move(); putBeeper();

Karel starts in the bottom left corner of a world that is any size (but always a rectangle). Karel must fill the entire world with beepers in a checkerboard pattern (alternating spaces). Karel can be facing east at the start, and can end anywhere.

turnAround(); while (frontIsClear()) move();

:

  • Type

Top cross linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram