Last active
August 30, 2022 06:39
-
-
Save aderchox/9e8444d29c58a5ffa6bd605b5925e527 to your computer and use it in GitHub Desktop.
Revisions
-
aderchox revised this gist
Aug 30, 2022 . 1 changed file with 36 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ void secureTheCave(){ turnLeft(); repeat(10){ goToEnd(); turnAround(); sweepBeepersToBottom(); situateInTheNextColumn(); } } void goToEnd(){ while(frontIsClear()){ moveForward(); } } void sweepBeepersToBottom(){ if(!onBeeper()){ goToEnd(); turnAround(); } else { pickBeeper(); moveForward(); sweepBeepersToBottom(); dropBeeper(); moveForward(); } } void situateInTheNextColumn(){ turnRight(); if(frontIsClear()){ moveForward(); turnLeft(); } } -
aderchox created this gist
Aug 30, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,79 @@ /* 0-0-0-0-1-1-1-1 0-0-1-1-0-0-1-1 0-1-0-1-0-1-0-1 —-1-1-c-1-c-c-1c */ void addFast(){ repeat(8){ addColumn(); } } void addColumn(){ if(!onBeeper() && !beeperAhead()){ moveForward(); if(beeperAhead()){ /* Uncommenting the two lines below will make the job more beautiful, but will also unfortunately fail the tests */ /* moveForward(); pickBeeper(); */ add1AtTheBottom(); } moveEnd(); moveToNextColumn(); moveEnd(); turnAround(); } else if((onBeeper() && !beeperAhead()) || (!onBeeper() && beeperAhead())){ moveForward(); if(beeperAhead()){ dropCarry(); } else { add1AtTheBottom(); moveToNextColumn(); } moveEnd(); turnAround(); } else { /* Both digits are 1 */ moveForward(); if(beeperAhead()){ /* Uncommenting the two lines below will make the job more beautiful, but will also unfortunately fail the tests */ /* moveForward(); pickBeeper(); */ add1AtTheBottom(); dropCarry(); } else { dropCarry(); } moveEnd(); turnAround(); } } void moveToNextColumn(){ turnRight(); moveForward(); turnRight(); } void moveEnd(){ while(frontIsClear()){ moveForward(); } } void dropCarry(){ moveEnd(); moveToNextColumn(); moveForward(); dropBeeper(); } void add1AtTheBottom(){ moveEnd(); dropBeeper(); }