Problem 017

Problem

Description

Jenny Cub and Apple Juice

Jenny Cub is finally learning some math. Like most young students, she is taught to add multi-digit numbers from right to left, one digit at a time. As with most children, Jenny Cub finds the "carry" operation, where a 1 is carried from one digit position to the next, a significant challenge. Your job is to help her count the number of carry operations for each set of addition problems.

Input

Each line of input contains two unsigned integers with no more than 10 digits. The last line of input contatains "0 0" and should not be processed. Here is an sample input:

123 456
555 555
123 594
0 0

Output

For each line of input except the last, compute the number of carry operations that result from adding the two numbers and print them in the format shown in this sample output:

No carry operation.
3 carry operations.
1 carry operation.

Note

This is based on "5.9.1 Primary Arithmetic" in "Programming Challenges" by Skiena and Revilla.

Solution

Approach

Store the numbers as strings and perform the addition digit by digit, keeping count of the number of carries.

Input/Output

Source Code