class program { define halfturn() { turnleft(); turnleft(); } define turnright() { iterate (3) turnleft(); } define buscaFinLinea() { while( notNextToABeeper && frontIsClear ) move(); while( nextToABeeper && frontIsClear ) move(); halfturn(); if( notNextToABeeper ) move(); } define recogeLinea() { turnright(); move(); turnleft(); while( frontIsClear ) { if( nextToABeeper ) pickbeeper(); move(); } if( nextToABeeper ) pickbeeper(); } define inicializa() { while( notFacingSouth ) turnleft(); while( frontIsClear ) move(); while( notFacingWest ) turnleft(); while( frontIsClear ) move(); halfturn(); buscaFinLinea(); recogeLinea(); turnleft(); move(); turnleft(); buscaFinLinea(); } define colocaLinea() { turnright(); move(); turnleft(); while( anyBeepersInBeeperBag ) { putbeeper(); if( frontIsClear ) move(); } halfturn(); buscaFinLinea(); } program() { inicializa(); while( anyBeepersInBeeperBag ) { colocaLinea(); recogeLinea(); turnleft(); move(); turnleft(); buscaFinLinea(); } turnoff(); } }