Ctrl K

Letter-Coded Addition

Easy
In a children's cipher, digits are replaced by letters: a is 0, b is 1, c is 2, and so on up to j for 9. A word reads as the number written with those digits: "cab" is 201, and "aad" is 3 (leading zeros are dropped). Given three words first, second and total, return True if the number for first plus the number for second equals the number for total, and False otherwise.
Example 1
first="bc", second="d", total="bf" → True

"bc" → 12, "d" → 3, "bf" → 15, and 12 + 3 = 15.

Example 2
first="aab", second="aj", total="ba" → True

Leading as are leading zeros: 1 + 9 = 10.

Example 3
first="j", second="j", total="bh" → False

9 + 9 = 18, but "bh" stands for 17.

Constraints
  • 1 ≤ len(first), len(second), len(total) ≤ 10
  • Words consist of letters from a to j
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsValue of a Roman Numeral EasyShared Start of Words EasyBracket Balance EasyWhere the Fragment Starts EasyLength of the Final Word Easy
loading Python…
Input
first="bc", second="d", total="bf"
Expected
True

Run checks the first 3 tests in your browser. Submit checks all 58 tests on the server, hidden ones included.