class program
   {
      define halfTurn()
         {
            turnleft();
            turnleft();
         }
      define pickOne()
         {
            if(nextToABeeper)
               pickbeeper();
         }
      define pickAllInRow()
         {
            pickOne();
            while(frontIsClear)
               pickOne();
         }
      define constructAnswer()
         {
            while(notFacingEast)
               turnleft();
            while(frontIsClear)
               move();
            halfTurn();
            if(nextToABeeper)
               {
                  while(anyBeepersInBeeperBag)
                     putbeeper();
                  pickOne();
               }
            else
               {
                  while(anyBeepersInBeeperBag)
                     putbeeper();
               }
            while(frontIsClear)
               {
                  move();
                  pickOne();
               }
            while(anyBeepersInBeeperBag)
               putbeeper();
            while(notFacingEast)
               turnleft();
            while(frontIsClear)
               move();
            while(nextToABeeper)
               pickbeeper();

            turnoff();
         }                                     
      define checkDone()
         {
            if(notNextToABeeper)
               constructAnswer();
            while(frontIsClear)
               {
                  move();
                  if(notNextToABeeper)
                     constructAnswer();
               }
         }
      define solve()
         {
            checkDone();
            halfTurn();
            while(nextToABeeper)
               {
                  pickOne();
                  while(frontIsClear)
                     {
                        move();
                        pickOne();
                     }
                  halfTurn();
                  checkDone();
                  halfTurn();
               }
         }
      program()
         {
             while(notFacingEast)
               turnleft();
             solve();
             turnoff();
         }
}
