← Back to challenges

Carrying the Digits

PythonHardnumbersmathcontrol_flow

Instructions

Write a function that returns the number of times you must carry a digit when you sum together two integers.

Examples

carry_digits(36, 135) ➞ 1
# You carry the 1 when you sum 6 and 5 together.

carry_digits(671, 329) ➞ 3

carry_digits(1111, 3333) ➞ 0

carry_digits(53214, 56905) ➞ 3

Notes

Count all carry operations (even those on leading digits).

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.