Name Compatibility
InterviewTime limit1sMemory limit512 MB
Interleave two equal-length names letter by letter, replace each letter with its stroke count, then repeatedly sum adjacent digits (keeping the ones digit) until two remain.
- Level
Easy3 of 10
- Topics
- Implementation, Simulation, Array, Math
- Solved
- No attempts yet
Problem
Name compatibility is a fortune game. Write the two names one letter at a time, alternating between them, and write the stroke count of each letter underneath. Then add every pair of neighboring numbers and write only the ones digit of each sum on the next line. Each line is one number shorter than the line above it, and the two numbers left at the end are the degree of compatibility.
Jongmin is a romantic who still has not forgotten 'her'. One day he tried name compatibility with her, and the result was a shock.

Jongmin could not accept the result at all, so he thought hard about how to prove it wrong and came up with this excuse.
"'She' is not Korean, so of course the result looks strange when the names are written in Hangul! If I write the names with the English alphabet, the common language of the world, the result will come out right!"
So Jongmin wants to write both names in uppercase letters and read the fortune again. He is afraid of slipping up while calculating by hand, so write the program for him. The stroke counts Jongmin decided on for uppercase letters are in the hint.
Input
The first line contains Jongmin's English name .
The second line contains the English name of 'her'.
and are strings of uppercase letters only, with length at least and at most , and the two names have the same length. When the fortune is read, the first letter of is written first.
Output
Print the result of the name compatibility as a two digit number. Print two digits even when the tens digit is .
Hint
The stroke counts of the uppercase letters, in order from A to Z, are 3, 2, 1, 2, 3, 3, 2, 3, 3, 2, 2, 1, 2, 2, 1, 2, 2, 2, 1, 2, 1, 1, 1, 2, 2, 1. They follow the way the problem setter writes uppercase letters.