1998. Programming Contest

Results

Ten teams from various schools in Idaho participated in the third High School programming contest. There were a total of 26 students and the teams were from the following schools: The first place team was from Centennial High School. The team members were Mike Rolig, Kevin Turner, Chris Callour. The second place team was also from Centennial High School. The team members were John O'Rorke, John Rotman, Tim Maness. A total of seven teams were able to finish one program correctly.

The Problems

Here are the problems used in the competition.






Problem 1: Squares

Description: Display the perimeter of an n by n square.

Input: A sequence of nonnegative integers n, one per line, terminated by 0.

Output: The perimeter of a square with sides n. An * should be used to denote the side of a square. Format each line so that there is a blank character between adjacent *s. Separate output from different squares by at least one blank line.

Example:

      Input:              Output:
        3                   * * *
        5                   *   *
        0                   * * *

                            * * * * *
                            *       *
                            *       *
                            *       *
                            * * * * *

Problem 2: Shifty Text

Description: Any one-to-one mapping, f, of any alphabet to itself can be used to encode text by replacing each occurrence of any letter, c, with f(c). One such mapping could be the mapping of a letter to three positions beyond the letter in the alphabet. That is, a --> d, b --> e, c --> f, d --> g and so on. With this mapping, ``The car is blue.'' will be encoded as ``Wkh fdu lv eoxh.''

Write a program that decodes the contents of its input file according to the following guidelines:

Example:
Input:  
3Whvw gdwd lv DEF ABC def abc

Output:
Test data is ABC XYZ abc xyz

Input:
9Rc'b j carlth xwn, cx bqxf qxf rc fxatb!

Output:
It's a tricky one, to show how it works!

Problem 3: Decoding Text

Description: Read the description for the previous problem (Shifty Text). Now suppose we do not know by how much the characters have been shifted. One possibility is to scan the text and build a frequency table (a histogram) of all the alphabetic characters. For the purposes of building the frequency table, we shall consider lower case and upper case characters to be equivalent. After building the table, we can find out the most frequently occurring character. From analysis of large number of English texts, it has been found that the character 'e' is the most frequently occurring character.

For example, suppose we find the character 'g' to be the most frequent character in the given encoded text. Then we conclude that the document was shifted by 2. Now we can decode the document as described in the Shifty Text problem.

Example:
Input:
Mtb yt mfaj ymj qfxy btwi ns wjfq qnkj ``Dtz'wj wnlmy!'' Mtb yt mfaj ymj
qfxy btwi ts Zxjsjy "Dtz'wj ns rd pnqqknqj!"


Output:
How to have the last word in real life ``You're right!'' How to have the
last word on Usenet "You're in my killfile!"