Posted on Leave a comment

My MidpointFindingKarel Algorithm

I am trying to solve the MidpointFindingKarel problem in the assignment 1 of Stanford’s CS106a. As of now, It is in my head but it still is not working perfectly.

I can lay down the beepers and have Karel move and pick them up one by one from one end to the other but I can’t have him stop at the middle.

  • lay down the beepers
  • move to the starting position
  • pick the beepers one at a time from one end to the other
  1. Lay down the beepers is easy. ┬áIt is just a “while” loop with the put beeper command in the body
  2. move to the starting position is just a “turnAround” and “movetowall” method
  3. This is the tough one which probably needs more decomposition. Still a work in progress.
Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.