Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

01 1 Prog Code JR

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

AMERICAN COMPUTER SCIENCE LEAGUE

2001-2002 CONTEST #1
JUNIOR DIVISION PROGRAMMING PROBLEM

WRAP AROUND CODE

PROBLEM: This is yet another in a long list of ACSL code programs. You would think we
would have run out of them by now. In this program you will be given a letter to encode. The
difference here is that different rules are used for different letters and the counting process can
cause you to wrap around the alphabet. Using the numerical value of each letter (A=1, B=2,
Z= 26) the rules are as follows:

If the letter is between the The number of letters to count is given by:
given letters, inclusive:
AE Multiply its numerical value by 2
F J Divide its numerical value by 3. Multiply the integer
remainder by 5
K O Divide its numerical value by 4. Multiply the integer part of
the quotient by 8.
PT Multiply the sum of the digits of its numerical value by 10
U- Z Find the largest integer factor of its numerical value less
than the value itself. Multiply it by 12.

As an example if the letter to encode is a B, the B has a numerical value of 2 and encodes to a 4
th
and becomes a D, the 4 letter of the alphabet. The G has a numerical value of 7. It encodes to a
5 and becomes an E. The numerical value of Z is 26. Its largest factor is 13. You must count
156 (13 12) letters. This has the effect of wrapping around the alphabet 6 complete times and
ending at Z. If a numerical value of zero is evaluated print a # symbol.

INPUT: There will be 5 input lines. Each will consist of an upper case letter.

OUTPUT: For each input line, print the encoded letter it produces.

SAMPLE INPUT SAMPLE OUTPUT


1. B 1. D
2. G 2. E
3. Z 3. Z
4. T 4. T
5. K 5. P

Note: Students have 72 hours in which to submit a solution. Students may not consult any person for assistance.
The program must accept all the data and print all the solutions in one RUN of the program. We suggest that you
print the solution for each input prior to entering the next input since, if the program stops, you will not be allowed
to enter the remaining data.. Make sure that you put your name, your school name and your division at the top of
your program file. Advisors must send to ACSL the program file of all students who score a 10 for the contest.

You might also like