[Karel] Unit8

Unit8


Lesson2

Before After
function main() {
   moveToWall();
}

function moveToWall(){
   while(frontIsClear()) {
      move();
   }
}

Lesson3

Before After
function main() {
   putBeeper();
   putBeeperLine();
}

function putBeeperLine(){
   while(frontIsClear()) {
      move();
      putBeeper();
   }
}

Lesson5

Before After
function main(){
   while(leftIsClear()){
      putBeeperLine();
      reset();
      moveUp();
   }
   putBeeperLine();
}

function putBeeperLine(){
   putBeeper();
   while(frontIsClear()){
      move();
      putBeeper();
   }
}

function reset(){
   turnLeft();
   turnLeft();
   while(frontIsClear()){
      move();
   }
   turnLeft();
   turnLeft();
}

function moveUp(){
   turnLeft();
   move();
   turnRight();
}

'Algorithm > Karel' 카테고리의 다른 글

[Karel] Unit9  (0) 2022.05.23
[Karel] Unit6  (0) 2022.05.23
[Karel] Unit5  (0) 2022.05.23
[Karel] Unit4  (0) 2022.05.23
[Karel] Unit3  (0) 2022.05.23