class program {
define faceEast()
   {
      while(notFacingEast)
         turnleft();
   }
define halfTurn()
   {
      turnleft();
      turnleft();
   }
define checkReminder()
   {
      if(nextToABeeper)
         {
            pickbeeper();
            if(nextToABeeper)
               {
                  pickbeeper();
                  move();
                  putbeeper();
                  halfTurn();
                  move();
                  halfTurn();
                  checkReminder();
               }
            else
               {
                  turnleft();
                  move();
                  putbeeper();
                  halfTurn();
                  move();
                  turnleft();
               }
         }
   }
program()
   {
      faceEast();
      while(nextToABeeper)
         {
            checkReminder();
            move();
         }
      turnoff();
   }
}
