# Sample Questions from the 2011 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-1699222
1700-1799233
1800-1899234
1900-2099245
2100-2199246
2200-2299250

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
2011In 2011 Easter is on April 24th
1886In 2011 Easter is on April 25th
2222In 2222 Easter is on March 31st
1820In 1820 Easter is on April 2nd
1988In 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)
1113Binary sum is 1010
1101106Binary sum is 111100
115Binary sum is 1000
101010Binary sum is 10100
01111111111111112500Binary 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
20345
51213
6810
81517
91215
121620
10345
6810
50345
51213
6810
72425
81517
91215
94041
102426
121620
123537
144850
152025
153639
163034
182430
202129
212835
243240
273645
304050

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
21The sum of the diagonals for 21 is 97
17The sum of the diagonals for 17 is 113
3The sum of the diagonals for 3 is 95
66That diagonal doesn’t exist.
27The 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

## Contact

Marwan Shaban
Program Manager
Phone: 407.708.2093
Fax: 407.708.2322
Office: V102-D