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.

  1. The list will be 20 numbers or less; all numbers will be integers (positive and negative) or 0.
  2. You do not need to edit this input. Only valid values will be entered.
  3. Display the largest number and how many times it appears in the list.
  4. The file (list) will contain at least one number.
  5. 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
  6. You can run each set of input numbers by copying the test input into your text file.
  7. The judges will enter additional test data not provided below to further test your application.

Test Data

InputOutput
1 2 300 4 5 6 7 8 9 1 2 300 4 5 6 7 8 9 300The largest number is 300 and it occurs 3 time(s).
0 -1 3 100 -10 0 43 -99 100 100The largest number is 100 and it occurs 3 time(s).
-10 -1 -3 -1 -10 -100 -34 -1 -33 -4 -1The 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).


    1. List will be 20 numbers or fewer; all numbers will be integers (positive, negative) or 0.
    2. The pivot number will appear only once at the beginning of the file.
    3. You do not need to edit this input. Only valid values will be entered.
    4. Display all the numbers less than the pivot, the pivot number, and then all the numbers greater than the pivot.
    5. The file (list) will contain at least one number.
    6. 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
    7. You can run each set of input numbers by copying the test input into your text file.
    8. The judges will enter additional test data not provided below to further test your application.

Test Data

InputOutput
7 2 99 8 5 4 9 8 2 3 55 44 3 900 12 12 5 4 2 3 3 1 7 99 8 9 8 55 44 900 12
10 8 12 4 16 118 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.

  1. 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.
  2. Read the number from the standard input device.
  3. You may use a console application or build a simple GUI application for the input and output.
  4. Display the output as shown in the Test Data below.
  5. Each input number can be tested by rerunning the application.
  6. The judges will enter additional test data not provided below to further test your application.

Test Data

InputOutput
31111331
1211111221
111221312211
31221113112221
55555555555888666661153856

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

InputOutput
Enter west edge temperature:90.0
Enter east edge temperature:80.0
Enter north edge temperature:70.0
Enter south edge temperature:60.0
Enter initial interior cells temperature: 10.0
Enter number of minutes: 2
Enter x-coordinate: 2
Enter y-coordinate: 2
The temperature of cell 2,2 is 18.75
Enter west edge temperature:40.0
Enter east edge temperature:80.0
Enter north edge temperature:40.0
Enter south edge temperature:80.0
Enter initial interior cells temperature: 60.0
Enter number of minutes: 100
Enter x-coordinate: 8
Enter y-coordinate: 8
The temperature of cell 8,8 is 78.90326
Enter west edge temperature:12.3
Enter east edge temperature:78.9
Enter north edge temperature:45.6
Enter south edge temperature:98.7
Enter initial interior value: 65.4
Enter number of minutes: 100
Enter x-coordinate: 5
Enter 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

 7070707070707070 
90101010101010101080
90101010101010101080
90101010101010101080
90101010101010101080
90101010101010101080
90101010101010101080
90101010101010101080
90101010101010101080
 6060606060606060 

West

South

Temperatures at minute 0


North

East

 7070707070707070 
904525252525252542.580
903010101010101027.580
903010101010101027.580
903010101010101027.580
903010101010101027.580
903010101010101027.580
903010101010101027.580
9042.522.522.522.522.522.522.54080
 6060606060606060 

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.

  1. Prompt for and accept as input:
    1. The number of glasses on the table
    2. The number of ounces of Gatorade in each glass
    3. Bob’s thirst level i.e., the minimum number of ounces required to satisfy his thirst)
  2. You do not need to edit this input. Only valid positive integer values will be entered.
  3. Read the numbers from the standard input device.
  4. 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.
  5. You may use a console application or build a simple GUI application for the input and output.
  6. Display the output as shown in the Test Data below.
  7. Each set of test data can be tested by rerunning the application.
  8. The judges will enter additional test data not provided below to further test your application.

Test Data

InputOutput
How many glasses are there?:
How many oz in glass 1: 8
How many oz in glass 2: 13
How many oz in glass 3: 22
How thirsty is Bob?: 24
Drink 1: 6 oz from glass 3 8 13 16
Drink 2: 4 oz from glass 3 8 13 12
Drink 3: 4 oz from glass 2 8 9 12
Drink 4: 3 oz from glass 3 8 9 9
Drink 5: 3 oz from glass 2 8 6 9
Drink 6: 3 oz from glass 3 8 6 6
Drink 7: 2 oz from glass 1 6 6 6

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

Drank: 17 oz
It 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.

  1. 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.
  2. Read the number from the standard input device.
  3. You may use a console application or build a simple GUI application for the input and output.
  4. Display the output as shown in the Test Data below.
  5. Each input number can be tested by rerunning the application.
  6. The judges will enter additional test data not provided below to further test your application.

Test Data

InputOutput
36Abundant Factors are: 1 2 3 4 6 9 12 18 
Sum is: 55
27Deficient Factors are: 1 3 9 
Sum is: 13
28Perfect Factors are: 1 2 4 7 14 
Sum is:  28
97Deficient Factors are:
Sum is: 1
100Abundant Factors are: 
1 2 4 5 10 20 25 50 
Sum is:
117
6Perfect 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:

  1. Start with an integer number > 0. Let’s call this n.
  2. Add the reverse order digits of n to n.
  3. 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.

  1. 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.
  2. Read the number from the standard input device.
  3. You may use a console application or build a simple GUI application for the input and output.
  4. Display the output as shown in the Test Data below.
  5. Each input number can be tested by rerunning the application.
  6. The judges will enter additional test data not provided below to further test your application.

Test Data

InputOutput
87Not a Lychrel number after 4 iterations: 4884
1689Not a Lychrel number after 4 iterations: 56265
196Still a Lychrel number after 10 iterations: 18211171
121Not a Lychrel number after 0 iterations: 121
786Not a Lychrel number after 3 iterations: 9339
9Not a Lychrel number after 0 iterations: 9
99Not a Lychrel number after 0 iterations: 99
3443Not 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”.

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

Test Data

InputOutput
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

Contact

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