[URI Online Judge] – 2508 – Fortune Teller

Link: https://www.urionlinejudge.com.br/judge/en/problems/view/2508

Clodovildo Procariontes Urus is a Fortune Teller, he uses numerology as a science that studies luck from numbers. An example of numerology application is in the calculation of luck from the person’s name. Many people worried about their own fortune end up changing their name to ensure a better luck. The calculation of the lucky number is based on the Pythagorean table, where each letter is translated to a number:

Once the letter has been translated by numbers, we add the sum and add the result digits until there is a value between 1 and 9. See, for example, the name “Harry Potter”: 8 + 1 + 9 + 9 + 7 + 7 + 6 + 2 + 2 + 5 + 9 = 65 → 6 + 5 = 11 → 1 + 1 = 2. The lucky number for Harry Potter is 2. Clodovildo has asked you for a program that calculates the lucky number from given names, with the number he can declare the luck of the person.


The input contains several test cases. Each test case has a name N on a single line, the name is composed of unaccented letters, and the cedilla is represented as the letter ‘C’, each name has at most 100 characteres.


For each input test case your program should generate for input name, a line with the Lucky Number.

Input SampleOutput Sample
Harry Potter
Hermione Granger
Albus Dumbledore