So, my current task is to create an algorithm that shifts piles of audio signals in line 1 on the right. I think I have a good start, I wrote code to pick up a bunch of beepers, move one to the right and leave these beepers:
public static void shift(Athlete arg) { int count = 0; while(!arg.nextToABeeper())
Strings of sound signals sometimes have gaps between the sound signals, and in this case this code works well, but if the adjacent beads are adjacent, the robot finishes dumping the first pile to the second pile, and I donβt know how to take the second pile signal, because now the second pile beepers consist of the first and second beepers, and I donβt know how to pick up only the second beepers.
Rofit Jane gave me the idea to start at the end of the line and go back. although I donβt think that this is how the problem should be solved, but this solution nonetheless. because there are gaps between the sound signals, and getting to the end of the line is actually more difficult than you might think. this is what i did in the end.
public static void goToEnd(Athlete arg) { while(!arg.nextToABeeper()) { arg.move(); } while(arg.nextToABeeper()) { arg.move(); } if(!arg.nextToABeeper()) { arg.move(); if(!arg.nextToABeeper()) { arg.turnAround(); arg.move(); } else { while(arg.nextToABeeper()) { arg.move(); } arg.turnAround(); } } }
source share