The solution uses three steps to transform the unary number:

  1. Decrement the unary number by one.
  2. Increment the binary number by one.
  3. If the unary number is bigger than zero, return to step 1.

Decrementing a unary number by one
The unary number can be decremented by one by simply removing the leftmost one.

Incrementing a binary number by one
To increment a binary number, every one is replaced by a zero starting from the right. This is done until the first zero is reached. This zero is then replaced by a one.