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