Spread the Pile
Medium · Functions
Karel is standing on a pile of balls at the start of the row. Spread the pile out so that each square, starting with Karel's square, gets exactly one ball, with no gaps. Finish back on the starting square.
One ball stays on the first square. Carry each other ball east to the first empty square, then walk back for the next one. Before carrying a ball away, check whether it was the last one left on the pile. The piles have different sizes in each world.
Next: Find the Middle