100-days-of-rust/Week-05/Day-34_Primary-Arithmetic
2024-08-28 11:39:14 +02:00
..
day34 Wrote program for Day 34 2024-08-28 11:39:14 +02:00
README.md Add files via upload 2023-03-23 21:14:34 -04:00

Primary Arithmetic

Children are taught to add multi-digit numbers from right to left, one digit at a time. Many find the “carry” operation, wherea 1 is carried from one digit position to the next, to be a significant challenge.

Your job is to count the number of carry operations for each of a set of addition problems so that educators may assess their difficulty.

Details

Write a carryOperations function. The function has the following parameters:

  • num1: first integer to sum
  • num2: second integer to sum

Returns:

  • Number of carry operations as an integer

Constraints

  • Input parameters are unsigned integers less than 10 digits.

Example

carryOperations(123, 456) ➞ 0
carryOperations(555, 555) ➞ 3
carryOperations(123, 594) ➞ 1
carryOperations(555, 545) ➞ 3
carryOperations(1, 20000) ➞ 0
carryOperations(1, 2) ➞ 0