At this moment, you are not allowed access to the question.

Junior Task. Digital Roots

Available Marks: 10

Numerologists ascribe certain magical properties to numbers, and in turn derive numbers from words or phrases. Nonsense like this can still provide an interesting computational exercise.

The two algorithms of interest to us are:

Write a program that reads in up to 20 lines, preceded by the number of lines. For each line, if it contains only a number, calculate and display the digital root, spaces and the number. If it's a phrase, calculate the letter sum, then display the digital root, the sum and the phrase, agsin separated by spaces. Input and calculated numbers are less than a billion and phases are shorter than 100 characters.

Example

Input:
5
123
the quick brown fox
7823438
"640 K ought to be enough for anybody". Bill Gates, 1981.
Progcomp
Output:
6       123
4       211     the quick brown fox
8       7823438
1       406     "640 K ought to be enough for anybody". Bill Gates, 1981.
4       103     Progcomp

Test Data

You should test your program on the following data:
14
99999
10000
7
12345678
98765432
June
UNSW Progcomp Twenty-thirteen
the second figure thrice
"Tragedy is when I cut my finger,...
Comedy is when you walk into an open sewer and die" (attributed to Mel Brooks).
the thirty-sixth triangular number, declared the number of the beast
A Clockwork Orange, Stanley Kubrick: 3*114+1=343
(114 was Kubrick's signature code, it appears in four films as CRM114 or serum 114 or C-rm114.)
Nineteen associates attacked the World Trade Center in New York and the Pentagon in Washington.

Marking Scheme

5 marks for correctly implementing the digit reduction algorithm and 5 for combining it correctly with the phrase analysis.

Step 0

Refresh the browser window if the page has been idle for some time.

Step 1

Cut and paste the output of your program for the supplied test data into the box below:

Step 2

Paste the source code for your program into the box below:

Step 3

When you are sure all the data has been entered correctly on the form press the submit button below.

You may submit multiple times. Only your most recent submission for each question will be marked.