Binary Addition
Hard · Algorithms
Rows 1 and 2 each hold a number in binary: a ball is a 1, an empty square is a 0, and the rightmost column is the smallest bit. Write their sum in binary on row 3. Leave rows 1 and 2 as they are.
Karel starts in the bottom-right corner, facing west. Add column by column from right to left, just like adding on paper: 0+0 is 0, 1+0 is 1, 1+1 is 0 and carry 1, and 1+1+1 is 1 and carry 1.
Your code runs in several worlds. The sum always fits in the row.
Next: Mark the Dead Ends