2000 Programming Contest

Results

Eleven teams from various schools in Idaho participated in the fifth High School programming contest.  A total of 33 students participated in the contest.

The first place team was from Centennial High School. The team members were John O'Rorke, Gunn Chang, Logan Kinde. The second place team was from Eagle High School. The team members were Chris Smith, Bart Robinson, Randy White. Both teams finished all three problems. The third team was from Boise High School. The team members were Mason Kinney, Kyle Schiepan, and Quincy Powell. Six teams finished at least one program correctly.

The Problems

Here are the problems used in the competition.
 
 
 
 


Problem 1: Secret Code

Description: You have just found an encoded message. You have also discovered the secret instructions on how this message was encoded. Here are the instructions: ``Calculate the message length and round up to the nearest multiple of 5. Write out the message in rows of 5 characters each until the message is complete. Send the message a column at a time from left to right.'' For example, suppose the message is THIS IS A CODED MESSAGE It is 23 characters long so two spaces are added at the end to make the message 25 characters long. The rows of five characters are:
1 2 3 4 5
T H I S 
I S   A
C O D E D
  M E S S 
A G E
The characters are sent one column at a time from left to right as shown below.
TIC~AHSOMGI~DEESAES~~~DS~$
A tilde represents a space (which implies that we cannot encode the tilde sign in our messages). The dollar sign indicates the end of the encoded message. Write a program that will decode any encoded message using the secret instructions.

Input: The program should read a message from the standard input. A message ends when you see the $ character. You may also assume that a encoded message has a maximum of 1000 characters.

Output: The program prints the decoded message.

Example:

Input:
mm~paveetatee~hr~ntie
ks.~n~~e~$

Output:
meet me in the park at seven.

Input:
TIC~AHSOMGI~DEESAES.~~DS~$

Output:
THIS IS A CODED MESSAGE. 

Input:
Ibt~Ino'ehb~'~veeudtienrti~t~~e~dd!$

Output:
I've been there but I didn't do it!

Problem 2: Prime Palindrome

Description: The number 151 is a prime palindrome because it is both a prime number and a palindrome (it is the same number when read forward as backward). Write a program that finds all prime palindromes between two numbers {\em start} and {\em end} given as input. You may assume that {\em start} and {\em end} are between 1 and 99,999.

Input: Two numbers are given as input.

Output: Output the numbers that are prime palindromes (one per line).

Example: The following example shows the program being run five times with five different inputs.

Input:   
1 200

Output:
1
2
3
5
7
11
101
131
151
181
191