Deviopath › Karel

Clean Up

Medium · Conditions

Some squares in the row have a ball. Pick up every ball and finish at the end of the row.

Use if (ballsPresent()) so Karel only calls takeBall() where there is a ball. Do not forget the last square: the loop stops before Karel checks it.

Next: Shift the Whole Pile