# Sample Questions from the 2016 Contest

## Description

Read a list of integer numbers from a text file. Each number in the file will be separated with a space. Find the largest number in the list and how many times that number appears in the list.

- The list will be 20 numbers or less; all numbers will be integers (positive and negative) or 0.
- You do not need to edit this input. Only valid values will be entered.
- Display the largest number and how many times it appears in the list.
- The file (list) will contain at least one number.
- The input will be provided for you to copy and paste into a text file. Internally name this file LargestNumber.txt and it must be stored in C:\Temp. Therefore, the entire file name will be C:\Temp\LargestNumber.txt
- You can run each set of input numbers by copying the test input into your text file.
- The judges will enter additional test data not provided below to further test your application.

## Test Data

Input | Output |
---|---|

1 2 300 4 5 6 7 8 9 1 2 300 4 5 6 7 8 9 300 | The largest number is 300 and it occurs 3 time(s). |

0 -1 3 100 -10 0 43 -99 100 100 | The largest number is 100 and it occurs 3 time(s). |

-10 -1 -3 -1 -10 -100 -34 -1 -33 -4 -1 | The largest number is -1 and it occurs 4 time(s). |

**Note:** You will be given access to a text file on the C:\Temp drive named LargestNumber.txt. This file will contain the first line of input from the above table. You will also have access to files named LargestNumber2.txt and LargestNumber3.txt containing the second and third lines of input from the above table. When you want to test with the second and third sets of data just open those files and paste the content into the LargestNumber.txt file.

## Description

Partition a list. Given a list of integer numbers and an integer pivot number, display all the numbers less than the pivot, the pivot number, and then all the numbers greater than the pivot. Read the list from a text file. The first number in the file will be the pivot number. The numbers before and after the pivot number must be in same order as found in the file (list).

- List will be 20 numbers or fewer; all numbers will be integers (positive, negative) or 0.
- The pivot number will appear only once at the beginning of the file.
- You do not need to edit this input. Only valid values will be entered.
- Display all the numbers less than the pivot, the pivot number, and then all the numbers greater than the pivot.
- The file (list) will contain at least one number.
- The input will be provided for you to copy and paste into a text file. Internally name this file PivotNumber.txt and it must be stored in C:\Temp. Therefore the entire file name will be C:\Temp\PivotNumber.txt
- You can run each set of input numbers by copying the test input into your text file.
- The judges will enter additional test data not provided below to further test your application.

## Test Data

Input | Output |
---|---|

7 2 99 8 5 4 9 8 2 3 55 44 3 900 12 1 | 2 5 4 2 3 3 1 7 99 8 9 8 55 44 900 12 |

10 8 12 4 16 11 | 8 4 10 12 16 11 |

0 -1 10 55 -23 -44 90 98 102 -1 -2 -33 2 -33 | -1 -23 -44 -1 -2 -33 -33 0 10 55 90 98 102 2 |

**Note:** You will be given access to a text file on the C:\Temp drive named PivotNumber.txt. This file will contain the first line of input from the above table. You will also have access to files named PivotNumber2.txt and PivotNumber3.txt containing the second and third lines of input from the above table. When you want to test with the second and third sets of data just open those files and paste the content into the PivotNumber.txt file.

## Description

Given a number, display the next number in the look-and-say sequence. The look-and-say sequence is determined by looking at the number, saying the number of times that each digit appears consecutively and then the digit itself. For example, given 3111 the next number in sequence would be 1331 because the number entered (3111) was composed of one 3 followed by three 1s.

- Prompt for and accept as input a positive integer having a minimum of one digit. You do not need to edit this input. Only valid positive integer values will be entered.
- Read the number from the standard input device.
- You may use a console application or build a simple GUI application for the input and output.
- Display the output as shown in the Test Data below.
- Each input number can be tested by rerunning the application.
- The judges will enter additional test data not provided below to further test your application.

## Test Data

Input | Output |
---|---|

3111 | 1331 |

1211 | 111221 |

111221 | 312211 |

312211 | 13112221 |

5555555555588866666 | 1153856 |

## Description

The New England Patriots have a heated field to keep it from freezing in cold temperatures. Under the grass is a grid of metal. A heat source is applied to the edges (east edge, west edge, south edge, and north edge). The heat source can apply a different constant temperature to each edge. The heat from the edges eventually is transmitted throughout the “grid” heating the entire field. We can think of this as a 10 x 10 grid as shown below.

North

East

West

South

Heat is only applied to the 8 “cells” that are shaded in the above figure. Heat is never applied to the corner cells. The same, constant heat is applied to each cell on a side. For example, if a heat source of 98 degrees is applied to the west side, all 8 cells on the west side have a constant heat source of 98 degrees. However, each side is controlled independently so if the west side has a constant heat source of 98 degrees the east, north, and south sides could each have a constant heat source with a different temperature. Once set, the heat source for a side doesn’t change.

Each interior cell has an initial temperature and this initial temperature is the same for all interior cells. Every minute the temperature of the interior cells change based on the heat applied to the edges and the temperature of the surrounding cells. The temperature of any “interior cell” becomes the average of its four surrounding cells. The groundskeeper would like to be able to enter the following data:

- Temperature applied to west edge
- Temperature applied to east edge
- Temperature applied to north edge
- Temperature applied to south edge
- Initial temperature of the interior cells
- Number of minutes to run the system
- The x coordinate of interior cell to report
- The y coordinate of the interior cell to report

Once the system has run the required number of minutes, the groundskeeper wants to be able to enter the X and Y coordinates of any interior cell and have the temperature of that cell reported. The groundskeeper believes with your application he can adjust the temperature of the field throughout the game to provide an advantage to the home team on cold days. (It is the Patriots after all.)

All temperature data will allow decimal numbers. The number of minutes and the x, y coordinates will be integer values. Temperatures could be negative. The minutes will always be > 0 and the x, y coordinates will always be valid for an interior cell (1, 1 through 8, 8). X runs from west to east and Y runs from north to south. You can print as many decimal positions as you want in the answer. Only the first 4 will be judged for accuracy.

## Test Data

Input | Output |
---|---|

Enter west edge temperature:90.0Enter east edge temperature:80.0Enter north edge temperature:70.0Enter south edge temperature:60.0Enter initial interior cells temperature: 10.0Enter number of minutes: 2Enter x-coordinate: 2Enter y-coordinate: 2 | The temperature of cell 2,2 is 18.75 |

Enter west edge temperature:40.0Enter east edge temperature:80.0Enter north edge temperature:40.0Enter south edge temperature:80.0Enter initial interior cells temperature: 60.0Enter number of minutes: 100Enter x-coordinate: 8Enter y-coordinate: 8 | The temperature of cell 8,8 is 78.90326 |

Enter west edge temperature:12.3Enter east edge temperature:78.9Enter north edge temperature:45.6Enter south edge temperature:98.7Enter initial interior value: 65.4Enter number of minutes: 100Enter x-coordinate: 5Enter y-coordinate: 6 | The temperature of cell 5,6 is 69.0748 |

**Hint:** The temperature of all interior cells change at the same time at the end of each minute. In other words, given the first set of test data above, the initial temperatures will be as follows.

North

East

70 | 70 | 70 | 70 | 70 | 70 | 70 | 70 | ||

90 | 10 | 10 | 10 | 10 | 10 | 10 | 10 | 10 | 80 |

90 | 10 | 10 | 10 | 10 | 10 | 10 | 10 | 10 | 80 |

90 | 10 | 10 | 10 | 10 | 10 | 10 | 10 | 10 | 80 |

90 | 10 | 10 | 10 | 10 | 10 | 10 | 10 | 10 | 80 |

90 | 10 | 10 | 10 | 10 | 10 | 10 | 10 | 10 | 80 |

90 | 10 | 10 | 10 | 10 | 10 | 10 | 10 | 10 | 80 |

90 | 10 | 10 | 10 | 10 | 10 | 10 | 10 | 10 | 80 |

90 | 10 | 10 | 10 | 10 | 10 | 10 | 10 | 10 | 80 |

60 | 60 | 60 | 60 | 60 | 60 | 60 | 60 |

West

South

Temperatures at minute 0

North

East

70 | 70 | 70 | 70 | 70 | 70 | 70 | 70 | ||

90 | 45 | 25 | 25 | 25 | 25 | 25 | 25 | 42.5 | 80 |

90 | 30 | 10 | 10 | 10 | 10 | 10 | 10 | 27.5 | 80 |

90 | 30 | 10 | 10 | 10 | 10 | 10 | 10 | 27.5 | 80 |

90 | 30 | 10 | 10 | 10 | 10 | 10 | 10 | 27.5 | 80 |

90 | 30 | 10 | 10 | 10 | 10 | 10 | 10 | 27.5 | 80 |

90 | 30 | 10 | 10 | 10 | 10 | 10 | 10 | 27.5 | 80 |

90 | 30 | 10 | 10 | 10 | 10 | 10 | 10 | 27.5 | 80 |

90 | 42.5 | 22.5 | 22.5 | 22.5 | 22.5 | 22.5 | 22.5 | 40 | 80 |

60 | 60 | 60 | 60 | 60 | 60 | 60 | 60 |

West

South

Temperatures at minute 1

**The value of 45 in cell 1, 1 was calculated as:** 70+90+10+10 / 4. **The value of 25 in cell 2, 1 was calculated as:** 70+10+10+10 / 4.

## Description

Bob has a drinking problem … not that kind of a problem. Bob drinks Gatorade, but he likes to have several glasses of Gatorade in front of him. He also has developed the problem that he must drink from the fullest glass, and must drink ¼ of the content of the glass. He always drinks a whole number of ounces of Gatorade. If ¼ of the glass is not an whole number of ounces, he will drink a little more to make it an whole number of ounces.

Bob’s wife prepares the glasses for him to drink from when he gets home from his tennis tournament. She puts Gatorade in each of the glasses, and lines them up. Each glass has a whole number of ounces. If there is more than one with the same amount, he chooses the one that is nearest to him. (Glass 1 is nearest.) He continues to drink until he has satisfied his thirst. He might drink more than his thirst level, but will not take another drink after he has had enough. There will always be enough Gatorade to satisfy his thirst. The problem is to find how many times he takes a drink of Gatorade to satisfy his thirst.

- Prompt for and accept as input:
- The number of glasses on the table
- The number of ounces of Gatorade in each glass
- Bob’s thirst level i.e., the minimum number of ounces required to satisfy his thirst)

- You do not need to edit this input. Only valid positive integer values will be entered.
- Read the numbers from the standard input device.
- For each drink, display the number of ounces in that drink and the glass. Also display the remaining ounces in each glass. When Bob has satisfied his thirst, display the total amount he drank and the total number of drinks. See the sample output below.
- You may use a console application or build a simple GUI application for the input and output.
- Display the output as shown in the Test Data below.
- Each set of test data can be tested by rerunning the application.
- The judges will enter additional test data not provided below to further test your application.

## Test Data

Input | Output |
---|---|

How many glasses are there?: 3 How many oz in glass 1: 8How many oz in glass 2: 13How many oz in glass 3: 22How thirsty is Bob?: 24 | Drink 1: 6 oz from glass 3 8 13 16Drink 2: 4 oz from glass 3 8 13 12Drink 3: 4 oz from glass 2 8 9 12Drink 4: 3 oz from glass 3 8 9 9Drink 5: 3 oz from glass 2 8 6 9Drink 6: 3 oz from glass 3 8 6 6Drink 7: 2 oz from glass 1 6 6 6Drank: 25 oz It took Bob 7 drinks to satisfy his thirst |

How many glasses are there?: 2 How many oz in glass 1: 17How many oz in glass 2: 19How thirsty is Bob?: 15 | Drink 1: 5 oz from glass 2 17 14Drink 2: 5 oz from glass 1 12 14Drink 3: 4 oz from glass 2 12 10Drink 4: 3 oz from glass 1 9 10Drank: 17 ozIt took Bob 4 drinks to satisfy his thirst |

## Description

Positive integers can be classified as abundant, deficient, or perfect. Abundant integers are those whose proper factors sum to a larger number. For example, 36 is an abundant number because its proper factors (1, 2, 3, 4, 6, 9, 12, 18) sum to 55 which is greater than 36. Deficient integers are those whose proper factors sum to a smaller number. For example, 27 is a deficient integer because its proper factors (1, 3, 9) sum to 13 which is less than 27. Perfect integers are those whose proper factors sum to exactly that number. For example, 28 is a perfect integer because its proper factors (1, 2, 4, 7, 14) sum to exactly 28. Given a positive integer value, determine if it is abundant, deficient, or perfect. Also list its perfect factors and the sum of those perfect factors.

- Prompt for and accept as input a positive integer having a minimum of one digit. You do not need to edit this input. Only valid positive integer values will be entered.
- Read the number from the standard input device.
- You may use a console application or build a simple GUI application for the input and output.
- Display the output as shown in the Test Data below.
- Each input number can be tested by rerunning the application.
- The judges will enter additional test data not provided below to further test your application.

## Test Data

Input | Output |
---|---|

36 | Abundant Factors are: 1 2 3 4 6 9 12 18 Sum is: 55 |

27 | Deficient Factors are: 1 3 9 Sum is: 13 |

28 | Perfect Factors are: 1 2 4 7 14 Sum is: 28 |

97 | Deficient Factors are: 1 Sum is: 1 |

100 | Abundant Factors are: 1 2 4 5 10 20 25 50 117Sum is: |

6 | Perfect Factors are: 1 2 3 Sum is: 6 |

**NOTE:** There are different definitions for proper factors. For this problem the definition of a perfect factor is a number that divides evenly into another number. This includes 1 but not the original number. For example, if the number is 39 then 1 is a perfect factor but 39 is not.

## Description

According to Wikipedia a Lychrel number is a “… natural number that cannot form a palindrome through the iterative process of repeatedly reversing its digits and adding the resulting numbers. “. The term "Lychrel" is credited to Wade VanLandingham formed as an anagram of his girlfriend’s first name – Cheryl. The process to find non-Lychrel numbers is the following:

- Start with an integer number > 0. Let’s call this n.
- Add the reverse order digits of n to n.
- Repeat the above two steps until the result is a palindrome.

Consider the number 87. Following the above rules we would need 4 iterations to get to a palindrome as follows:**Iteration 1:** 87 + 78 = 165**Iteration 2:** 165 + 651 = 726**Iteration 3:** 726 + 627 = 1353**Iteration 4:** 1353 + 3531 = 4884

The result in iteration 4 is 4884 which is a palindrome. Therefore 87 is NOT a Lychrel number. No Lychrel numbers have been proven to exist. In fact most numbers coalesce into a palindrome fairly quickly. However some do not. The best known of these is the number 196. You could execute tens of thousands of iterations starting with 196 and not calculate a palindrome.

In this problem you must show a positive integer is NOT a Lychrel number by determining how many iterations are required before the process creates a palindrome. Display the number of iterations and the resulting palindrome number. To avoid long run times, stop after a maximum of 10 iterations. If a number has not coalesced into a palindrome after 10 iterations display the output shown below for input value 196.

- Prompt for and accept as input a positive integer having a minimum of one digit. You do not need to edit this input. Only valid positive integer values will be entered.
- Read the number from the standard input device.
- You may use a console application or build a simple GUI application for the input and output.
- Display the output as shown in the Test Data below.
- Each input number can be tested by rerunning the application.
- The judges will enter additional test data not provided below to further test your application.

## Test Data

Input | Output |
---|---|

87 | Not a Lychrel number after 4 iterations: 4884 |

1689 | Not a Lychrel number after 4 iterations: 56265 |

196 | Still a Lychrel number after 10 iterations: 18211171 |

121 | Not a Lychrel number after 0 iterations: 121 |

786 | Not a Lychrel number after 3 iterations: 9339 |

9 | Not a Lychrel number after 0 iterations: 9 |

99 | Not a Lychrel number after 0 iterations: 99 |

3443 | Not a Lychrel number after 0 iterations: 3443 |

## Description

Given 3 different integer numbers, determine if the difference between the smallest number and the middle number is the same as the difference between the middle number and the largest number. The numbers can be entered in any order. If the differences are exactly the same the program should indicate the numbers are “Spaced Out” otherwise the numbers are “NOT Spaced Out”.

- Prompt for and accept as input three integers. You do not need to edit this input. Only valid positive integer values will be entered.
- Read the numbers from the standard input device.
- You may use a console application or build a simple GUI application for the input and output.
- Display the output as shown in the Test Data below.
- Each set of input numbers can be tested by rerunning the application.
- The judges will enter additional test data not provided below to further test your application.

## Test Data

Input | Output |
---|---|

Enter number 1: 3 Enter number 2: 5 Enter number 3: 7 | Spaced Out |

Enter number 1: 7 Enter number 2: 5 Enter number 3: 3 | Spaced Out |

Enter number 1: 7 Enter number 2: 3 Enter number 3: 5 | Spaced Out |

Enter number 1: 5 Enter number 2: 9 Enter number 3: 6 | NOT Spaced Out |

Enter number 1: 10 Enter number 2: 10 Enter number 3: 10 | Spaced Out |

Enter number 1: 8 Enter number 2: 6 Enter number 3: 6 | NOT Spaced Out |

Enter number 1: 6 Enter number 2: 8 Enter number 3: 6 | NOT Spaced Out |

Enter number 1: 6 Enter number 2: 6 Enter number 3: 8 | NOT Spaced Out |