1.3.4: Tower Karel, 1.3.5: Gold Medal Karel, 1.3.6: Maze Karel

Code for these lessons:

1.3.4: Tower Karel

  1. move();
  2. turnLeft();
  3. putBall();
  4. move();
  5. putBall();
  6. move();
  7. putBall();
  8. move();
  9. turnLeft();
  10. turnLeft();
  11. turnLeft();

1.3.5: Gold Medal Karel

  1. move();
  2. putBall();
  3. move();
  4. putBall();
  5. move();
  6. putBall();
  7. turnLeft();
  8. move();
  9. turnLeft();
  10. move();
  11. putBall();
  12. turnLeft();
  13. turnLeft();
  14. turnLeft();
  15. move();
  16. turnLeft();
  17. turnLeft();
  18. turnLeft();

1.3.6: Maze Karel

  1. while(frontIsClear()){
  2.      move();
  3.      if(frontIsBlocked()){
  4.           turnLeft();
  5.      }
  6. }
  7. turnLeft();
  8. turnLeft();
  9. while(frontIsClear()){
  10.      move();
  11.      if(frontIsBlocked()){
  12.           turnLeft();
  13.           turnLeft();
  14.           turnLeft();
  15.      }
  16.      if(frontIsBlocked()){
  17.           turnLeft();
  18.      }
  19.      while(frontIsClear()){
  20.           move();
  21.           if(frontIsBlocked()){
  22.                turnLeft();
  23.                turnLeft();
  24.                turnLeft();
  25.           }
  26.           if(frontIsBlocked()){
  27.                turnLeft();
  28.                turnLeft();
  29.           }
  30.      } 
  31. }
  32. turnLeft();
  33. turnLeft();
  34. turnLeft();

Comments

Popular posts from this blog

1.9.5: Marathon Karel, 1.9.6: Take 'em All, 1.9.7: Dizzy Karel, 1.9.8: For Loop Square, 1.9.9: Lots of Hurdles

1.4.4: Slide Karel, 1.4.5: Fireman Karel

1.5.4: Pancakes, 1.5.5: Mario Karel