Want more info?Melinda White Did you know...Seminole State has a 15 credit Web programming certificate that prepares you to develop your own website. |
Previous Competition Sample Problems
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Samples from the 2011 Programming Contest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Expand all samples | Contract all samples
|
| a = year mod 19 |
| b = year mod 4 |
| c = year mod 7 |
| d = (19a + M) mod 30 |
| e = (2b + 4c + 6d + N) mod 7 |
The values for M and N are provided in the following table.
| Year | M | N |
|---|---|---|
| 1583-1699 | 22 | 2 |
| 1700-1799 | 23 | 3 |
| 1800-1899 | 23 | 4 |
| 1900-2099 | 24 | 5 |
| 2100-2199 | 24 | 6 |
| 2200-2299 | 25 | 0 |
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:
Print the day of the month using the proper ordinal suffix (st, nd, rd, th) after day of the month.
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 Year | Output |
|---|---|
| 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 |
Add comments at the top of your source code for your name and the problem number.
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.
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
A sample graphical user interface is provided below. Your user interface is not being judged.

Figure 5 – Sample Graphical User Interface
Create an application that accepts a binary number and a decimal number as input. Add these numbers. Display the sum as a binary number.
You may use the Calculator utility in Accessories on your PC.
Only valid binary and decimal numbers will be entered.
Decimal numbers will be in the range from 0 >= d <= 50,000.
Binary numbers will be in the range from 0 >= b <= 50,000.
Use the following data to test your application. Match the output exactly.
| Binary Number Input | Decimal Number Input | Output (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 |
The judges will enter additional data not provided in the table above to further test your application.
Add comments at the top of your source code for your name and the problem number.
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.
A sample console interface is provided below. Your user interface is not being judged.

Figure 2 – Console Interface
A sample graphical user interface is provided below.

Figure 3 – Graphical User Interface
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.
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.
Prompt the user for a maximum value. The value will be an integer and not exceed 500.
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.
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
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.
Do not print any combination that has “a” equal to zero or “b” equal to zero.
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.
The output you should receive for various maximums are listed below.
| Maximum | a | b | c |
|---|---|---|---|
| 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 |
The judges will enter a different maximum than those specified above to further test your application.
Add comments at the top of your source code for your name and the problem number.
You may use the Calculator utility in Accessories on your PC.
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
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 |
The user will enter an integer value. All numbers will be in the range 0 > n < 100.
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.
| Input | Output |
|---|---|
| 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 |
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 |
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 |
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.
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 |
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 |
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.
A number will occur in the array only once.
Remember the number input by the user must only be included in the sum once.
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.
Add comments at the top of your source code for your name and the problem number.
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
A sample graphical user interface is provided below. Your user interface is not being judged.

Figure 8 – Sample Graphical User Interface
Expand all samples | Contract all samples
Read two lists of integers. Compare the lists using the AND, OR, XOR and NOR operations.
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:
| Operation | Description |
|---|---|
| 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. |
8 3 7 1 -1
1 2 3 4 5 6 7 8 9 0 -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
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
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:
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
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).
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.
Output for a single random combination is listed below.
Number Number * 365
...... ........
271123 98959895
...... ........
Create an application that converts Arabic base 10 numbers into Roman numerals.
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 Number | Roman Number |
|---|---|
| 1 | I |
| 5 | V |
| 10 | X |
| 50 | L |
| 100 | C |
| 500 | D |
| 1000 | M |
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 |
|---|---|
| 2000 | MM |
| 1996 | MCMXCVI |
| 592 | DXCII |
| 1091 | MXCI |
| 1886 | MDCCCLXXXVI |
Expand all samples | Contract all samples
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.
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.
| 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 |
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 deathlibe 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.
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.
| 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 |
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 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.
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.
| 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.
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:
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 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.
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) |
| Like us on Facebook | Follow us on Twitter | Watch us on YouTube | View our photos on Flickr | Subscribe to our RSS Feed |