# Programming Competition

## Previous Competition Sample Problems

Samples from the 2012 Programming Contest

## Problem Description

The most common form of Universal Product Code (UPC) is UPC-A which has 12 digits arranged to make a unique number. The twelfth digit is a check digit calculated based on the values in digits one through eleven. Calculate a UPC-A check digit given the eleven digits.

## Detail Requirements

1. Read eleven single digit numbers. You must enter these as one complete “number” and not as individual digits or characters. This means you must enter the digits and press the enter key once to have your application read the entire “number” if you are using a console application. You cannot enter each digit individually and click a button to process it if you are using a graphical user interface. Enter all the digits and then click the process button once.
2. Only numbers will be entered as test data. No letters, spaces, or special characters will be entered.
3. To calculate the check digit:
1. Add the digits in the odd numbered positions (first, third, fifth, …).
2. Multiply the above sum by three.
3. Add the digits in the even numbered positions (second, fourth, sixth, …) to the total from above.
4. Find the remainder when you divide the result by ten.
5. The check digit is zero if the remainder is zero. Otherwise subtract the remainder from ten to get the check digit.
4. Display the original “number” and the check digit.
6. The judges will enter additional data not provided above to further test your application. Only valid numbers will be entered as test data. Each set of test data can be tested by rerunning the application.
7. A sample console interface is provided below. Your user interface is not being judged. Each set of data can be tested by rerunning the application.
Enter the UPC code minus the check digit: 01600027559
Check digit for 01600027559 is 1
8. A sample graphical user interface is provided below. Your user interface is not being judged. Each set of data can be tested by rerunning the application.

## Test Data

 Input Output 01600027559 Check digit for 01600027559 is 1 74953850500 Check digit for 74953850500 is 6 40010068896 Check digit for 40010068896 is 0

## Problem Description

A numeric sequence is a series of numbers in which the relation of a number to the one that follows it is the same. For example, 1, 2, 3, 4 and 3, 6, 12, 24 are both sequences. In the first sequence each number is one less than the one that follows it. In the second sequence, each number is one-half the one that follows it. Two types of numerical sequences are arithmetic and geometric. The first sequence is arithmetic because each number differs from its predecessor by the same value - in this case 1. The second sequence is geometric because each number differs from its predecessor by the same multiplication factor - in this case 2.

The term for a sequence is the value at any given location. Given the sequence 3, 6, 12, 24, the first term is 3, the third term is 12, and the fifth term would be 48.

Determine whether a list of numbers is a sequence (arithmetic or geometric) and the type. Determine the value of the Nth term if the list is a sequence.

## Detail Requirements

1. Prompt the user to enter a maximum of 10 numbers. The user can signify the end of data entry before 10 numbers by entering 99999. Display an error and end the application if fewer than three numbers are entered.
2. Prompt the user to enter an integer number (N) for the Nth term in the sequence.
3. Determine if the list of numbers entered is an arithmetic sequence, a geometric sequence, or neither. Print one of the following:
1. The list is an arithmetic sequence.
2. The list is a geometric sequence.
3. The list is not a sequence.
4. Display the value of the Nth term if the list is a sequence.
6. The judges will enter additional data not provided above to further test your application. Only integer numbers will be entered as test data. No letters, spaces, or special characters will be entered. Each set of test data can be tested by rerunning the application.
7. A sample console interface is provided below. Your user interface is not being judged. Each set of data can be tested by rerunning the application.
Enter up to 10 numbers:
Number 1: 7
Number 2: 9
Number 3: 11
Number 4: 13
Number 5: 15
Number 6: 99999
Enter N for the ninth term: 27
The list is a(n) arithmetic sequence
8. A sample graphical user interface is provided below. Your user interface is not being judged. Each set of data can be tested by rerunning the application.

## Problem Description

A series of right triangles can be inscribed (nested) within each other as shown in the figure below. The original right triangle has three smaller triangles nested inside. The area of each nested triangle obviously decreases as it gets smaller. The goal is to determine the area of the right triangle nested at a specific level.

The area of a right triangle is ½ (base * height). The height for a right triangle is the line perpendicular to the base. In the outer triangle above, the base is b and the height is a. The sides of each nested triangle are ½ the length of its parent triangle. For example, if a = 30, b = 40, and c = 50 then the equivalent sides for the first nested triangle are 15, 20, and 25 respectively. You are given a set of three (x,y) coordinates for an outer triangle. You are also given the number of nested triangles. Use this information to determine the area of the triangle at that level.

A Cartesian coordinate system is used as displayed below. The 3 (x,y) coordinates for the given right triangle are (-7,5), (-7,-5), and (5,-5).

1. Accept three sets of x,y coordinates representing the points of a right triangle.
2. The coordinates are guaranteed to form a right triangle when lines are drawn between them. The coordinate pairs must be entered one number at a time. See the sample user interface below.
3. The base of the triangle is always parallel to either the X or Y axis.
4. Accept a number representing how many levels of nesting must occur.
5. Display the area of the right triangle at that level.
7. The judges will enter additional data not provided above to further test your application. Only integer numbers will be entered as test data. No letters, spaces, or special characters will be entered. Each set of test data can be tested by rerunning the application.
8. A sample console interface is provided below. Your user interface is not being judged. Each set of data can be tested by rerunning the application.

Enter x1:5
Enter y1:5
Enter x2:45
Enter y2:5
Enter x3:5
Enter y3:35
Enter how many nested triangles doyou want: 3
The areofnested triangle 3 is 9.375
9. A sample graphical user interface is provided below. Your user interface is not being judged. Each set of data can be tested by rerunning the application.

## Problem Description

Derwin is trying to convince his teacher that Pig Latin is an appropriate foreign language. He says he speaks and writes Pig Latin fluently. He also informs his professor that none other than Thomas Jefferson used to write his friends in Pig Latin. Derwin’s professor, always a good sport, plans to translate all Derwin’s assignments for the rest of the semester into Pig Latin but needs help. You will help by writing an English to Pig Latin translation program.

## Detail Requirements

1. Read a sentence from the console. The sentence will end with the “word” zzzzz. The zzzzz is a marker indicating the end of the input. Do not translate it to Pig Latin.
2. Replace each English word with its Pig Latin equivalent. There are two basic rules.
1. Add “way” to the word if it starts with a vowel (a, e, i, o, u). The English word “each” becomes the Pig Latin word "eachway".
2. If the word doesn’t start with a vowel, take all the consonants from the beginning of the word up to (but not including) the first vowel. Move these to the end of the word. Add "ay". The English word "brick" becomes the Pig Latin word "ickbray".
3. Keep the u with the q in words with the "qu" combination. The English word "quit" becomes the Pig Latin word itquay. We will ignore the few English words that have a q but no following u. Also you can assume that the qu combination will always be followed by a vowel. There will never be more than one letter q in a word.
4. The letter y is normally considered a consonant except when there are no vowels in the word like "try". Treat the y as a vowel in this case and follow the rules of 2b. The English word "try" would become the Pig Latin word "ytray".
5. Maintain the proper case of the word. The Pig Latin word must be uppercase if the English word begins with an uppercase letter. The English word Floridian would be Oridianflay. The phrase:
Go to School John.zzzzz
Would translate as:
Ogay otay oolschay ohnjay Notice the capitalization of the Ogay and Ohnjay.
6. Punctuation marks will only occur at the end of words and must be reproduced at the end of the respective Pig Latin word. The phrase:
John, it is time to leave! zzzzz
Would translate as:
Ohnjay, itway isway imetay otay eavelay!
8. The judges will enter additional data not provided above to further test your application. Only letters, spaces and punctuation will be entered as test data. A single space will separate each word. Each set of test data can be tested by rerunning the application.
9. A sample console interface is provided below. Your user interface is not being judged. Each set of data can be tested by rerunning the application.

## Test Data

Input 1
Derwin, here is your assignment for this week. Make sure you try all the problems! zzzzz

Output 1
Erwinday, erehay isway ouryay assignmentway orfay isthay eekway. Akemay uresay ouyay ytray allway ethay oblemspray!

Input 2
The assignment is not hard but you must start early. Do not delay. The quiz is Thursday. zzzzz

Output 2
Ethay assignmentway isway otnay ardhay utbay ouyay ustmay artstay earlyway. Oday otnay elayday. Ethay izquay isway Ursdaythay.

Samples from the 2011 Programming Contest

## Problem Description

Easter can occur as early as March 22nd and as late as April 25th. The problem is it moves around from year to year. The exact day of the year can be calculated based on a formula by the German mathematician Friedrich Gauss. Create an application to determine the date of Easter for any year between 1583 and 2299.

## Detail Requirements

1. Use the following calculations:

 a = year mod 19 b = year mod 4 c = year mod 7 d = (19a + M) mod 30 e = (2b + 4c + 6d + N) mod 7
Figure 1
2. The values for M and N are provided in the following table.

YearMN
1583-1699 22 2
1700-1799 23 3
1800-1899 23 4
1900-2099 24 5
2100-2199 24 6
2200-2299 25 0
Figure 2
3. If d + e is less than 10 then Easter is on the d + e + 22 of March. Otherwise Easter is on the d + e – 9 of April. You must also incorporate the following exceptions:

1. Easter can never be on April 26. If the calculated date is April 26, shift it to April 19.
2. If the calculated date is April 25, with d = 28, e = 6, and a > 10 then Easter is on April 18.
4. Print the day of the month using the proper ordinal suffix (st, nd, rd, th) after day of the month.

5. Prompt the user to enter the year for which the date of Easter is to be calculated. Read the year. Use this input and the formula above to calculate the date for Easter. Below is sample input and output. Match the sample output exactly for the given sample input.

Input YearOutput
2011 In 2011 Easter is on April 24th
1886 In 2011 Easter is on April 25th
2222 In 2222 Easter is on March 31st
1820 In 1820 Easter is on April 2nd
1988 In 1988 Easter is on April 3rd
Figure 3

7. The judges will enter additional data not provided in the table above to further test your application. Only valid four digit years between 1583 and 2299 (inclusive) will be entered as test data.

8. A sample console interface is provided below. Your user interface is not being judged. Each set of data can be tested by rerunning the application. It is not necessary to create a user controlled loop.

Figure 4 – Sample Console Interface

9. A sample graphical user interface is provided below. Your user interface is not being judged.

Figure 5 – Sample Graphical User Interface

## Problem Description

Create an application that accepts a binary number and a decimal number as input. Add these numbers. Display the sum as a binary number.

## Detail Requirements

1. You may use the Calculator utility in Accessories on your PC.

2. Only valid binary and decimal numbers will be entered.

3. Decimal numbers will be in the range from 0 >= d <= 50,000.

4. Binary numbers will be in the range from 0 >= b <= 50,000.

5. Use the following data to test your application. Match the output exactly.

Binary Number InputDecimal Number InputOutput (Sum in Binary Format)
111 3 Binary sum is 1010
110110 6 Binary sum is 111100
11 5 Binary sum is 1000
1010 10 Binary sum is 10100
0111111111111111 2500 Binary sum is 1000100111000011
Figure 1 – Test Input and Output
6. The judges will enter additional data not provided in the table above to further test your application.

8. You may use simple console input and output for this application. Each set of data can be tested by rerunning the application. It is not necessary to create a user controlled loop.

9. A sample console interface is provided below. Your user interface is not being judged.

Figure 2 – Console Interface

10. A sample graphical user interface is provided below.

Figure 3 – Graphical User Interface

11. You must enter the binary number as one complete number and not as individual numbers or characters. This means you must enter the binary number and press the enter key once to have your application read the entire binary number if you are using a console application. You cannot enter each binary digit individually and press the enter key after each. Likewise in a graphical user interface application, you cannot enter each binary digit individually and click a button after each.

## Problem Description

The Pythagorean Theorem states that a2 + b2 = c2. The most well known combination is 3, 4, and 5 since 32 + 42 = 52. Find all combinations of a, b, and c that fit this theory given a, b, and c must each be less than or equal to a maximum number entered by the user.

## Detail Requirements

1. Prompt the user for a maximum value. The value will be an integer and not exceed 500.

2. The value of “a” cannot exceed the user supplied maximum. The value of “b” cannot exceed the user supplied maximum. The value of “c” cannot exceed the user supplied maximum.

3. Determine and print all combinations of a, b, and c such that the following are true:

2 <= a <= user entered maximum
2 <= b <= user entered maximum
2 <= c <= user entered maximum
a2 + b2 = c2

4. Do not print duplicates. That is 3, 4, 5 is valid but 4, 3, 5 is a duplicate. 6, 8, 10 is valid but 8, 6, 10 is a duplicate.

5. Do not print any combination that has “a” equal to zero or “b” equal to zero.

6. Print “a” then “b” and then “c” in your output as a heading. Then print each combination of a, b, and c on its own line. Separate each number by two blank spaces. The sample output for 10 is:

a  b  c
3  4  5
6  8  10

You do not need to “align” the columns. See the sample output in Figure 2.

7. The output you should receive for various maximums are listed below.

Maximumabc
20 3 4 5
5 12 13
6 8 10
8 15 17
9 12 15
12 16 20
10 3 4 5
6 8 10
50 3 4 5
5 12 13
6 8 10
7 24 25
8 15 17
9 12 15
9 40 41
10 24 26
12 16 20
12 35 37
14 48 50
15 20 25
15 36 39
16 30 34
18 24 30
20 21 29
21 28 35
24 32 40
27 36 45
30 40 50
Figure 1 – Sample Input and Output
8. The judges will enter a different maximum than those specified above to further test your application.

10. You may use the Calculator utility in Accessories on your PC.

11. A sample console interface is provided below. Your user interface is not being judged. The sample output shows all valid values for “a”, “b”, and “c” not greater than 100. That is, a <= 100, b <= 100, and c <= 100.

Figure 2 – Sample Console Interface

## Problem Description

Given the array below, calculate and display the total of the left diagonal sum and the right diagonal sum.

 22 13 2 8 30 14 21 18 25 27 7 4 10 3 15 5 17 12 11 16 23 6 1 9 24
Figure 1 – Original Array

## Detail Requirements

1. The user will enter an integer value. All numbers will be in the range 0 > n < 100.

2. Display an error message if the value entered doesn’t exist in the array. Otherwise display the sum of the left and right diagonals of the array. Format your output exactly as shown below.

InputOutput
21 The sum of the diagonals for 21 is 97
17 The sum of the diagonals for 17 is 113
3 The sum of the diagonals for 3 is 95
66 That diagonal doesn’t exist.
27 The sum of the diagonals for 27 is 56
Figure 2 – Test Input and Output
3. The left diagonal sum is the sum of all the numbers running from the matching input number to the upper left/top edge of the array and to the lower right/bottom edge of the array. For example, if 17 is entered the left diagonal sum is 25 (17 + 1 + 7) as shown below.

 22 13 2 8 30 14 21 18 25 27 7 4 10 3 15 5 17 12 11 16 23 6 1 9 24
Figure 3 – Left Diagonal for 17
4. The right diagonal sum is the sum of all the numbers running from the matching input number to the upper right/top edge of the array and to the lower left/bottom edge of the array. For example, if 17 is entered the right diagonal sum is 105 as shown below (17 + 10 + 25 + 30 + 23).

 22 13 2 8 30 14 21 18 25 27 7 4 10 3 15 5 17 12 11 16 23 6 1 9 24
Figure 4 – Right Diagonal for 17
5. The sum of the diagonals for 17 is 113. This is calculated as the left diagonal plus the right diagonal but the diagonal value itself (17) is only counted once.

6. If 2 is entered, the left diagonal sum is 42 as shown below (2 + 25 + 15)

 22 13 2 8 30 14 21 18 25 27 7 4 10 3 15 5 17 12 11 16 23 6 1 9 24
Figure 5 – Left Diagonal for 7
7. If 2 is entered, the right diagonal sum is 30 as shown below (2 + 21 + 7).

 22 13 2 8 30 14 21 18 25 27 7 4 10 3 15 5 17 12 11 16 3 6 1 9 24
Figure 6 – Right Diagonal for 7
8. The sum of the diagonals for 2 is 70. This is calculated as the left diagonal (42) plus the right diagonal (30) but remember the diagonal value itself (2) is only counted once.

9. A number will occur in the array only once.

10. Remember the number input by the user must only be included in the sum once.

11. In addition to using the test data, the judges will also change the array values given in Figure 1 and test with new input values not provided to you.

13. A sample console interface is provided below. Your user interface is not being judged. Each set of data can be tested by rerunning the application. It is not necessary to create a user controlled loop.

Figure 7 – Sample Console Interface

14. A sample graphical user interface is provided below. Your user interface is not being judged.

Figure 8 – Sample Graphical User Interface

Samples from the 2006 Programming Contest

## Problem Description

Read two lists of integers. Compare the lists using the AND, OR, XOR and NOR operations.

## Input/Output

Your application should prompt and read a maximum of 10 digits. The digits will be in the range of 0 to 9. The user will enter a -1 to end the list if less than 10 numbers are entered. Separate each number entered by a space. Once the first list is entered, repeat the process for a second list of integers. The second list can be the same length, longer or shorter than the first list. Each list can have any combination of the numbers 0 through 9. Each list must have at least one number.

Once both lists are entered, apply each of the follow operations to the lists:

OperationDescription
AND Print all numbers that occur in both lists. These are the numbers the lists have in common.
OR Print all numbers that occur in either list.
XOR Print all numbers that occur in one list but not the other.
NOR Print all numbers that are not in either list.

## Sample Input 1:

8 3 7 1 -1

1 2 3 4 5 6 7 8 9 0 -1

## Output 1:

A  OR  B  =  0 1 2 3 4 5 6 7 8 9

A  NOR  B  =

A  AND  B  =  1 3 7 8

A  XOR  B  =  0 2 4 5 6 9

0 -1

3 2 8 -1

## Output 2:

A  OR  B  =  0 2 3 8

A  NOR  B  =  1 4 5 6 7 9

A  AND  B  =

A  XOR  B  =   0 2 3 8

## Problem Description

Read a single word and print the word as a rectangle. The word will be a maximum of 40 characters long and a minimum of two characters long.

The format of the rectangle will be:

1. The word will read left to right when starting from the upper-left corner of the rectangle.
2. The word will read top to bottom when starting from the upper-left corner of the rectangle.
3. The word will read bottom to top when starting from the lower-right corner of the rectangle.
4. The word will read right to left when starting from the lower-right corner of the rectangle.

## Input/Output

Your application should accept a single word input from the keyboard. The word will be a maximum of 40 characters long and a minimum of two characters long. Print the word in the format described below. Stop the application after printing the word rectangle.

Sample Input 1:

bookstore

Sample Output 1:

bookstore
o       r
o       o
k       t
s       s
t       k
o       o
r       o
erotskoob

Sample Input 2:

it

Sample Output 2:

it
ti

## Problem Description

Find all numbers that, when multiplied by 365, produce an eight-digit product where the first four digits of that product are equal to the last four digits of that product. For example, 271123 x 365 produces an eight-digit product (98959895) whose first four digits (9895) are equal to its last four digits (9895).

## Input/Output

There is no input for this problem.

The output will be a list of the first 10 integers that, when multiplied by 365, create an eight-digit product where the first four digits of that product are equal to the last four digits of that product. Also, print the product of the number and 365. Submit a second version of your application that prints all of the numbers (not just the first 10) so the judges can see the last 10 numbers generated.

## Sample Output

Output for a single random combination is listed below.

Number        Number * 365

......        ........

271123        98959895

......        ........

## Problem Description

Create an application that converts Arabic base 10 numbers into Roman numerals.

## Input/Output

Your application should accept a single integer value input from the keyboard. This number will be in the range from 0 to 2000. Convert the number entered to its Roman numeral equivalent if the numbered entered is greater than zero. After converting to and displaying the Roman numeral, prompt the user to enter another number. Repeat these steps as long as the user enters an integer greater than zero.

End the application when the user enters a zero for the number to convert.

The highest number you must convert is 2000.

Your output will be the Roman numeral equivalent to the Arabic number entered. Each Roman numeral "letter" should be displayed in upper case. Below are the Roman numeral symbols you will use and some conversion rules.

Arabic NumberRoman Number
1 I
5 V
10 X
50 L
100 C
500 D
1000 M
1. Generally, a string of Roman numerals indicates adding the values. For example, CLX would be 100 + 50 + 10, or 160. Notice that each Roman numeral is preceded by a Roman numeral that represents a larger value: L is larger than X, and C is larger than L. Placing a smaller Roman number in front of a larger Roman numeral indicates subtraction. For example, IV means 1 - 5, or 4.
2. No more than three of the same Roman numeral may be used sequentially. For example, the Roman numeral for 8 is VIII, but the Roman numeral for 9 is IX, not VIIII. VIIII can't be used because it requires the symbol I to be used four times sequentially.
3. You can subtract I, X, L, C or D, but not V.
4. Subtract only a single Roman numeral from a single Roman numeral. For example, 8 is VIII not IIX. You can't subtract II from X because II is two Roman numerals, not one.
5. Don't subtract a letter from another letter more than 10 times greater than itself. For example, the Roman numeral I can be subtracted from V or X only. X can be subtracted from X or L only.

## 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.

InputOutput
2000 MM
1996 MCMXCVI
592 DXCII
1091 MXCI
1886 MDCCCLXXXVI
Samples from the 2005 Programming 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

InputOutput
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 PhraseKeywordEncrypted 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

InputOutput
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.

InputOutput
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)