Reverse the Row
Hard · Algorithms
The row has piles of balls. Reverse it: the pile from the first square goes to the last square, the second one to the second-to-last square, and so on.
Your code runs in several worlds. A list (array) is a handy way to remember every pile you counted.
Next: Checkerboard