Sample Questions from the 2005 Contest
Problem Description
Create a program that reads three integer numbers. Each of these numbers represents one side of a triangle. The program must determine if lines of these three lengths could be used to create a triangle. If a triangle could be created, the program must further determine if that triangle would be an equilateral triangle, an isosceles triangle, a right triangle or a regular triangle.
Assume three lines can make a triangle if the sum of the lengths of the two shorter lines is greater than or equal to the length of the longest line. For example, you can make a triangle given lines of lengths 5, 3 and 7 because 5 + 3 is greater than 7. However, you cannot make a triangle with lines of lengths 3, 5 and 9 because 3 + 5 is less than 9.
If the lines can make a triangle, determine if the triangle is an equilateral triangle, an isosceles triangle, a right triangle or a regular triangle. An isosceles triangle is one in which two of the three sides are equal and the conditions above are met. An equilateral triangle is one in which all three sides are equal and the conditions above are met. A right triangle is one in which the sum of the squares of two sides equals the sum of the square of the third side and the conditions above are met. For example, a triangle with side lengths of 3, 4 and 5 is a right triangle because 32 + 42 = 52.
>Input
Three positive integer values representing the three sides of a triangle will be entered. You do not need to edit to ensure that only numbers are entered. You may request the input be entered at one time or use three separate prompts — one for each input value. The values for the line lengths can be entered in any order. For example, you can't assume that the longest length will always be entered first, nor can you assume that the lengths will always be entered in descending or ascending order.
Your values may be input as a single set of data or as a grouping of three individual pieces of data. Your application can be created to process a single set of data. That is, after processing a set of data, your application can end. You can then start the application again and enter a second set of data. If you use a graphical interface (Visual Basic, C#, etc.), you can enter the data in text boxes and display the results in text boxes or labels. However, a graphical interface is not required for this application. If you create a command line application, you can prompt for the input numbers one at a time or enter them all in a single input statement.
Sample Input/Output
Input | Output |
---|---|
3 4 5 | Right triangle |
3 5 3 | Isosceles triangle |
2 10 2 | Not a triangle |
3 3 3 | Equilateral triangle |
5 10 20 | Not a triangle |
10 0 5 | Not a triangle |
7 14 20 | Regular triangle |
Problem Description
In this problem, each letter of the alphabet corresponds to a number using the scheme: a=1, b=2, c=3, ... y=25, z=26. To encode a message, an encryption key word is added to the message. The key word is the first word in the message that is five or more characters long. For example, if the message were:
"give me liberty or give me death," the key word would be "liberty." The encrypted message would be:
s r x j e y k u k g w l s n d p k a w g d p n c y z
The first letter, s, results from adding 7 for the letter "g" to 12 for the letter "l." The sum is 19, which creates the letter "s." The other letters are calculated in a like manner. The algorithm you develop should wrap around to the beginning of the alphabet if the sum of two letters exceeds 26. For example, when the letter "l" (12) is added to "y" (25), the sum is 37. Since there is no 37th letter in the alphabet, you should subtract 37 from 26 to get the number 11, which equates to the letter "k."
The key word is repeated indefinitely to the end of the message. For example:
give me liberty or give me death
libe rt ylibert yl iber ty liber
--------------------------------
srxj ey kukgwls nd pkaw gd pncyz
(Spaces are left between the words in this example for clarity. Do not include spaces in your results.)
Every message will have at least one five-letter word.
Spaces are not encrypted and not included in the output. Only messages in lowercase letters will be entered. No punctuation or special characters will be entered.
Input/Output
When encrypting, the input will consist of a sentence or phrase entered via the standard input device. The output must be the key and the encrypted message. Only lowercase letters will be entered, so it is not necessary to edit the input.
A text file will be provided with the sentences and phrases displayed below. You can copy and paste these for testing purposes to save time. They do not constitute the complete set of testing data the judges will use.
Your application can be created to process a single set of data. That is, after processing a set of data, your application can end. You can then start the application again and enter a second set of data. If you use a graphical interface (Visual Basic, C#, etc.), you can enter the data in text boxes and display the results in text boxes or labels. However, a graphical interface is not required for this application.
Sample Input/Output
Input Phrase | Keyword | Encrypted Output |
---|---|---|
a stitch in time saves nine | stitch | t m c c w k a c w n l u x m j p h a g c w y |
it is a rainy day | rainy | a u r g z j b r b x v b h |
it only hurts when i laugh | hurts | q o g h e g c m l m a r z y g q g s o z p |
jack and jill went to the hills | hills | r j o w t v m v u e t f q z m b x f t x p r x x l |
Problem Description
Create an application that removes duplicate entries from a list of numbers. Your application will process a maximum of 20 integer numbers. Each number will be equal to or greater than zero. You do not need to edit for floating point numbers or invalid characters. Twenty is the maximum number of values to be entered. The user must be able to enter 0 numbers, 1 number, 20 numbers or any amount between 1 and 20. If you create a command-line application, allow the user to enter -1 to indicate that no more numbers will be entered. Once the input is complete, the application must indicate which numbers are duplicated and how many duplicates existed for each number.
Input
Input will be a series of integers separated by at least one space. Any number of integers from 0 to 20 may be entered. The user must be able to enter 0 numbers, 1 number, 20 numbers or any other count of numbers between 0 and 20 inclusive. You do not need to edit to ensure that only numbers are entered. Only integer numbers will be entered.
Your values may be input as a single set of data or as a grouping of individual pieces of data. Your application can be created to process a single set of data. That is, after processing a set of data, your application can end. You can then start the application again and enter a second set of data. If you use a graphical interface (Visual Basic, C#, etc.), you can enter the data in text boxes and display the results in text boxes or labels. However, a graphical interface is not required for this application. If you create a command-line application, you can prompt for the input numbers one at a time or enter them all in a single input statement.
Output
Print the original list of numbers entered. Next, print a list of any numbers that were duplicated and the number of duplicates. Finally, print the revised list of numbers minus any duplicates.
Sample Input/Output
Input | Output |
---|---|
1 2 3 4 5 1 6 1 7 1 8 1 9 1 10 -1 | 1 2 3 4 5 1 6 1 7 1 8 1 9 1 10 Value 1: 5 copies are deleted 1 2 3 4 5 6 7 8 9 10 |
1 2 1 2 1 2 1 2 3 4 5 3 -1 | 1 2 1 2 1 2 1 2 3 4 5 3 Value 1: 3 copies are deleted Value 2: 3 copies are deleted Value 3: 1 copies are deleted 1 2 3 4 5 |
23 23 23 23 23 23 23 -1 | 23 23 23 23 23 23 23 Value 23: 6 copies are deleted 23 |
8 7 33 19 22 57 -1 | 8 7 33 19 22 57 No duplicate values 8 7 33 19 22 57 |
18 -1 | 18 No duplicate values 18 |
-1 | No duplicate values |
The last row in the table above indicates that no values were entered.
Problem Description
Create an application that correctly calculates time segments. A segment of time can be represented as a number of days (d), a number of hours (h), a number of minutes (m) and a number of seconds (s). For example, a valid time segment would be:
12 days, 6 hours, 5 minutes and 49 seconds.
Valid output values for each component of time are as follows:
- days (d) > 0
- hours (h) > 0 and < 24
- minutes (m) > 0 and < 60
- seconds (s) > 0 and < 60
The input values for the time segments will not conform to the above rules. The application must determine invalid values and convert them to valid values. For example, the time segment:
23 30 45 93
indicates that days = 23, hours = 30, minutes = 45, and seconds = 93. The equivalent valid time segment would be:
24 days, 6 hours, 46 minutes and 33 seconds.
This is based on 93 seconds being converted to 1 minute and 33 seconds. The one minute is added to the input value of 45, resulting in 46 minutes. The input value of 30 hours is converted to one day (24 hours) and 6 hours. The one day is added to the input value of 23, resulting in 24 days.
Consider a second example below:
0 105 99 120
This example indicates 0 days, 105 hours, 99 minutes and 120 seconds. The equivalent valid time segment would be:
4 days, 10 hours and 41 minutes.
This is based on 120 seconds being converted to 2 minutes, and 105 days being converted to 4 days and 10 hours. Note that there is no time segment for seconds because that would be 0. Omit any time segment if it would be zero.
There are 60 seconds in a minute, 60 minutes in a hour and 24 hours in a day.
Input/Output
Input for this application will be a series of four integer values representing, in order, the days, hours, months and seconds as described above. However, the input values for d, h, m and s can be any integer value equal to or greater than zero. You do not need to edit to ensure that only numbers are entered. Only positive integer numbers will be entered.
The output will be a valid time segment in the format:
a days, b hours, c minutes and d seconds.
Omit any time segment if it would be zero.
Your values may be input as a single set of data or as a grouping of four individual pieces of data. Your application can be created to process a single set of data. That is, after processing a set of data, your application can end. You can then start the application again and enter a second set of data. If you use a graphical interface (Visual Basic, C#, etc.), you can enter the data in text boxes and display the results in text boxes or labels. However, a graphical interface is not required for this application. If you create a command-line application, you can prompt for the input numbers one at a time or enter them all in a single input statement.
Sample Input/Output
Your application must provide the following results for the given input. Your output must be formatted as indicated in the Output column below.
Input | Output |
---|---|
20 0 125 64 | 20 day(s), 2 hour(s), 6 minute(s), 4 second(s) |
0 23 110 6000 | 1 day(s), 2 hour(s), 30 minute(s) |
1 51 0 33 | 3 day(s), 3 hour(s), 33 second(s) |
22 23 75 80 | 23 day(s), 16 minute(s), 20 second(s) |
7 50 40 301 | 9 day(s), 2 hour(s), 45 minute(s), 1 second(s) |