Sample Questions from the 2014 Contest

Contract All | Expand All

Digital Root

Description

The digital root of a number is obtained by summing its individual digits, summing those individual digits, and continuing the process until the final sum is a single digit (that is, less than 10). For example, the digital root of 1234 is 1. That result is calculated as:

1 + 2 + 3 + 4 = 10

1 + 0 = 1

Detail Requirements

  1. Prompt the user to enter a non-negative integer number. Only valid integer values will be entered. You do not need to edit this number.
  2. Display the original number and the digital root.
  3. Each set of data can be tested by rerunning the application.
  4. Add comments at the top your source code file for your name and the problem number.
  5. The judges will enter additional test data not provided below to further test your application. You don’t need to validate the input. The judges will only enter valid data.

Test Data

InputOutput
1234 The digital root of 1234 is 1
12576 The digital root of 12576 is 3
0 The digital root of 0 is 0
450900 The digital root of 450900 is 9
Line Up

Description

A group of boys and girls line up by height in separate classrooms – boys in one room and girls in a different room. Eventually they must be merged into one line arranged by height with the shortest student first. You need to write an application that merges a list containing the heights of the girls with a list containing the heights of the boys.

Detail Requirements

  1. Ask the user to enter the number of boys in the class. Then ask the user to enter that number of height values. The height values for the boys will be entered in order from the shortest to the highest.
  2. Ask the user to enter the number of girls in the class. Then ask the user to enter that number of height values. The height values for the girls will be entered in order from the shortest to the highest.
  3. The heights will be integer values between 40 and 72. You do not need to edit this value.
  4. The number of boys may not match the number of girls. There may be more girls or more boys. There will be at least one boy and at least one girl. There will be a maximum of 15 boys and a maximum of 15 girls.
  5. Display the list of heights in order from the shortest to the highest.
  6. Add comments at the top your source code file for your name and the problem number.
  7. The judges will enter additional test data not provided below to further test your application. You don’t need to validate the input. The judges will only enter valid 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.

    Enter number of boys:
    5
    Enter values for boys separated by a space
    48 55 66 69 71
    Enter number of girls:
    3
    Enter values for girls separated by a space
    44 51 55
    Line up: 44 48 51 55 55 66 69 71

Test Data

InputOutput
Number of boysList of boys’ heightsNumber of girlsList of girls’ heights 
5 52  56  63  66  67 3 48   53  54   Line up: 48  52  53  54  56  63  66  67
5 48  55  66  69  71 3 44  51  55 Line up: 44  48  51  55  55  66  69  71
1 55 8 40  42  42  48  54  56 57 58 Line up: 40  42  42  48  54  55  56  57  58
4 40  44  46  50 4 43  45  48  52 Line up: 40  43  44  45  46  48  50  52
I’m Out of Gas

Description

A driver has run out of gas in a large city. Fortunately the city area is laid out in a grid and maps exactly to a Cartesian coordinate system. “Streets” run north-south and “Avenues” run east-west. Each block is exactly the same distance.

Each street is numbered in order from the x axis with “West” indicating the street is west of the axis and “East” indicating it is east of the axis. The y axis is Main Street so West 9th Street is 9 blocks west of Main Street.

Each Avenue is also numbered in order from the y axis with “North” indicating the avenue is north of the y axis and “South” indicating it is south of the y axis. The x axis is Main Avenue. So South 14th Avenue is 14 blocks south of Main Avenue.

The city center is at the intersection of Main Street and Main Avenue. These are pedestrian walkways so there are no gas stations located on Main Street or Main Avenue. In addition the driver can never be stranded there because you can’t drive on these streets.

The driver can always determine his closest street intersection by looking at the street signs. The driver also has a cell phone but it is not a smart phone (due to the expense). The driver can call directory assistance and get the phone numbers of gas stations in the area and then call the gas stations to get their nearest street intersection. Help the driver by finding the closer of two gas stations.

Remember this is a city so you cannot walk diagonally through buildings. You must walk in straight lines east or west on Streets and north or south on Avenues.

Problem 3: I'm Out of Gas Diagram

Detail Requirements

  1. Ask the user to enter the intersection closest to the driver’s current location.
  2. Ask the user to enter the intersection closest to the first gas station.
  3. Ask the user to enter the intersection closest to the second gas station.
  4. Determine which gas station is closer to the driver and display the number of that gas station as well as the number of blocks to get there. Display the number of blocks and that both stations are the same distance if appropriate. See the sample output below.
  5. The intersection values will be in the following format: direction number. For example, West 3rd Street at North 5th Avenue would be entered as w 3 n 5. Each value is separated by a space. All intersection values will be valid. You do not need to edit these values.
  6. Each set of data can be tested by rerunning the application.
  7. Add comments at the top your source code file for your name and the problem number.
  8. The judges will enter additional test data not provided below to further test your application. You don’t need to validate the input. The judges will only enter valid data.

Test Data

 PromptsInputOutput
1 Enter your location (street  avenue):
Enter location of gas station #1 (street avenue):
Enter location of gas station #2 (street avenue):
e 4 n 3
w 4 n 3
w 4 s 2
Walk 8 block(s) to gas station #1!
2 Enter your location (street  avenue):
Enter location of gas station #1 (street avenue):
Enter location of gas station #2 (street avenue):
e 1 s 3
w 3 n 4
w 4 s 2
Walk 6 block(s) to gas station #2!
3 Enter your location (street  avenue):
Enter location of gas station #1 (street avenue):
Enter location of gas station #2 (street avenue):
w 4 s 2
w 5 s 2
w 4 s 3
Both gas stations are 1 block(s) away!
Treasure Hunt

Description

Search an array to discover a hidden treasure. The clues for the location of the treasure are contained in the array. You are given a 5 by 5 array filled with integers. Each element in the array will contain an integer value between 11 and 55. Starting with the first cell (row 1, column 1), use the value found there to locate the next clue. The value in the cell is the next cell you should “visit”. The tens position of the value is the row and the ones position of the value is the column. A value of 35 would indicate the next clue is in row 3 column 5. Access that cell and look for another clue. Continue following the clues until the cell you visit has a value that is equal to its location in the array. For example, the cell at row 4 column 2 has a value 42. That is the cell with the treasure.

Display the row and column for each cell you visit as well as the cell that has the treasure.

Detail Requirements

  1. Create a 2 dimensional array like one of the sample arrays below. All test arrays are 5 by 5. Each element contains an integer value between 11 and 55.
  2. The treasure hunt always starts with the cell in the first row and first column.
  3. Hard code each array so there is no user input.
  4. All clues are valid and all treasure hunts have a locatable treasure.
  5. Each set of data can be tested by changing the array and rerunning the application.
  6. Add comments at the top your source code file for your name and the problem number.
  7. The judges will enter additional test data not provided below to further test your application. You don’t need to validate the input. The judges will only enter valid data.
Test Data 1Test Data 2Test Data 3

Given the following array

35 11 11 11 11
11 11 11 11 11
11 11 11 11 42
11 42 11 11 11
11 11 11 11 11

The result will be:
Started at 1 1
Visited 3 5
Visited 4 2
Treasure is at 4 2

Given the following array:

55 21 32 41 25
21 42 43 14 31
54 45 52 42 23
33 15 51 31 35
21 52 33 13 51

The result will be:
Started at 1 1
Visited 5 5
Visited 5 1
Visited 2 1
Treasure is at 2 1

Given the following array:

34 21 32 41 25
14 42 43 14 31
54 45 52 42 23
33 15 51 31 45
21 52 33 13 23

The result will be:
Started at 1 1
Visited 3 4
Visited 4 2
Visited 1 5
Visited 2 5
Visited 3 1
Visited 5 4
Visited 1 3
Visited 3 2
Visited 4 5
Treasure is at: 4 5

Let’s Go Bowling!

Description

Process a stream of numbers representing the scores from a game of bowling. Scoring in bowling is done by counting the number of pins toppled with each roll of a ball. Bowling has 10 “frames” or opportunities to score ten points. Each frame starts with ten pins upright. The player has the opportunity to roll a ball twice per frame with the goal of knocking down the ten pins. The score for each frame is the number of pins knocked down. In addition the following scoring rules exist.

  1. If any combination of ten pins is toppled in one frame, that frame is scored as ten points plus the score of the next ball thrown. The combination of ten total pins toppled with two balls is called a “spare”.
  2. If the first ball in a frame topples all the pins, that frame is scored as ten points plus the score of the next two balls rolled. A second ball is not rolled in the frame in this case. Toppling all the pins on the first ball is called a “strike”.
  3. The tenth frame is the last frame. If any combination of ten pins is toppled on the first two balls thrown (a spare), the player is allowed to roll a third ball. The score on this third ball is added to the total score. If all ten pins are toppled with the first ball (a strike), the player is allowed to roll two more balls. The score on each ball is added to the total score.

Failure to get a strike or a spare in a frame results in what is called an “open” frame. It is possible to throw a “gutter ball” knocking down zero pins and get a score of 0.

Detail Requirements

  1. Read a series of integer numbers from the standard input device.  Each number, except the last, will be between 0 and 10 inclusive. The numbers represent the bowling scores. You do not need to edit the numbers as only valid integer values will be entered. The last number entered will be a number greater than 10 indicating the end of the data.
  2. Each number entered represents the number of pins toppled with a throw of the bowling ball.
  3. List the number of pins toppled in each frame and the score of the game after that frame. See the sample results below.
  4. A frame will consist of two numbers (the bowling ball being rolled twice) if the first ball did not topple all ten pins. A frame will consist of one number (the bowling ball being rolled once) if the first ball did topple all ten balls.
  5. The minimum number of scores that can be entered for a bowling game is 11. This is the result of rolling one ball for each of nine frames and two balls in the tenth. The maximum number of scores that can be entered for a bowling game is 21. This is the result of rolling two balls for each of nine frames and rolling three balls in the tenth frame. The “extra” ball comes from rolling a strike with the first ball in the tenth frame. You do not need to edit to make sure the correct number of scores are entered for a bowling game. The correct number of scores will always be entered.
  6. The score by frame can be displayed after all the scores are entered.
  7. Each set of data can be tested by rerunning the application.
  8. Add comments at the top your source code file for your name and the problem number.
  9. The judges will enter additional test data not provided below to further test your application. You don’t need to validate the input. The judges will only enter valid data.
  10. 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 next score: 6
Enter next score: 3
Enter next score: 7
Enter next score: 3
Enter next score: 9
Enter next score: 1
Enter next score: 10
Enter next score: 9
Enter next score: 1
Enter next score: 8
Enter next score: 1
Enter next score: 10
Enter next score: 6
Enter next score: 3
Enter next score: 9
Enter next score: 0
Enter next score: 8
Enter next score: 1
Enter next score: 99

Frame Score
1 9
2 28
3 48
4 68
5 86
6 95
7 114
8 123
9 132
10 141

Test Data

Input scores 7  3  8  1  6  4  9  0  9  1  2  6  9   1  9  0  8  2  8  0  99
Results
Frame Score
1 18
2 27
3 46
4 55
5 67
6 75
7 94
8 103
9 121
10 129
 
Input scores 10 10 10 10 10 10 10 10 10 10 10 10 99
Results
Frame Score
1 30
2 60
3 90
4 120
5 150
6 180
7 210
8 240
9 270
10 300
Bananas

Description

A group of passengers are shipwrecked on a deserted island. They immediately start gathering bananas for food. The plan is to share the bananas equally. During the first night on the island one of the passengers decides to take his share so he divides the bananas into equal piles based on the number of passengers. One banana was left over which he decided to give to a nearby monkey. He then hid his share of the bananas, put the other bananas back, and then went back to sleep. Shortly another passenger woke up and did the same thing. In fact, each passenger woke up and did the same thing. The next morning when everyone woke up, they divided the remaining bananas equally and had none left over. Assuming there were 25 bananas initially, we can find there were 3 shipwrecked passengers using the following process.

Passenger Starting Number of bananas Bananas in Each Pile
(1 pile for each passenger)
Bananas for Monkey
1 25 8 8 8 1
2 16 5 5 5 1
3 10 3 3 3 1
  6 2 2 2 0

We know there could not be 4 passengers as the process would not leave exactly one banana for the monkey when the second passenger divides up the remaining 19 bananas. This is shown below.

Passenger Starting Number of bananas Bananas in Each Pile
(1 pile for each passenger)
Bananas for Monkey
1 25 6 6 6 6 1
2 18 4 4 4 4 2 (Must be 1)

In this problem you will be given the initial number of bananas collected. You have to determine the maximum number of passengers that could have been shipwrecked following the same procedure. Remember to include the bananas for the monkey. It is possible that no solution exists. In that case display “no solution exists”.

Detail Requirements

  1. Prompt the user to enter the number of bananas collected. This will be an integer value between 0 and the largest value possible for an integer. You do not need to edit this number. Only valid integer values will be entered.
  2. Display the largest number of shipwrecked passengers possible given the process that is described above. Use the output format given below.
  3. Add comments at the top your source code file for your name and the problem number.
  4. The judges will enter additional test data not provided below to further test your application. You don’t need to validate the input. The judges will only enter valid data.
  5. Each set of data can be tested by rerunning the application.

Test Data

Input (Number of bananas) Output
25 25 bananas: 3 people and 1 monkey
30 30 bananas has no solution
3121 3121 bananas: 5 people and 1 monkey
233275 233275 bananas: 6 people and 1 monkey
823537 823537 bananas: 7 people and 1 monkey
Spy Talk

Description

One of the little known strategies of covert CIA agents is that they can identify each other in the field using a secret strategy.  When they meet each other, the first covert agent will say a greeting to the second, who must respond using words that contain only letters that appear in the original greeting. In this problem you will be given a greeting and a response. You must determine if the response identifies a CIA spy.

Detail Requirements

  1. Read a greeting from the console. The greeting can be of any length and may contain numbers, letters, spaces, and punctuation marks.
  2. Read a response from the console. The response can be of any length and may contain numbers, letters, spaces, and punctuation marks.
  3. The greeting and response will not necessarily be the same length.
  4. Display “That’s my secret contact!” if the response contains only letters from the greeting. Ignore the case of the letters when comparing the greeting and response. Ignore any numbers, spaces, and punctuation marks when comparing the greeting and response.
  5. Display “You’re not a secret agent!” if the response contains a letter that doesn’t exist in the greeting.
  6. Add comments at the top your source code file for your name and the problem number.
  7. The judges will enter additional test data not provided below to further test your application. You don’t need to validate the input. The judges will only enter valid data.
  8. Each set of data can be tested by rerunning the application.

Test Data

InputOutput
GreetingResponse
Good evening. Hello there. You’re not a secret agent!
Dogs can't fly without umbrellas. Bread is a stale food. That’s my secret contact!
It’s nice to meet you, George! Greetings to you too, Tim! That’s my secret contact!
It’s raining. I sang in a train. That’s my secret contact!
Broken Remote Control

Description

The TV remote control is broken. Only certain buttons work. You must write an application that determines the minimum number of button pushes necessary to move from one channel to the next. The TV channels go from 1 to 9999. The user will enter the starting channel and the ending channel as well as which buttons work.

Detail Requirements

  1. Prompt the user to enter an integer number between 1 and 9999 representing the starting channel number. Prompt the user to enter an integer number between 1 and 9999 representing the ending channel number. Only valid integer values in the correct range will be entered. You do not need to edit these numbers.
  2. Prompt the user to enter the TV remote buttons that work. This will integers between 0 and 9. Leave a space between each number and terminate the input with the value 99. The sequence 0  5  9 99 would indicate that the 0, 5, and 9 buttons are the only number buttons that work on the remote. The sequence 0 1 2 3 4 6 7 8 9 99 would indicate all the buttons except the 5 work on the remote.
  3. The channel up button always works. It moves the channel up by one. Moving up one from channel 9999 takes you to channel 1.  There is no channel 0.
  4. The channel down button always works. It moves the channel down by one.  Moving down one from channel 1 takes you to channel 9999. There is no channel 0.
  5. The enter button must always be pressed after digits are entered. It is not necessary to press enter after channel up or channel down. If used, count the enter button as one of the buttons pressed.
  6. There are 5 possible options for getting to the correct ending channel from any starting channel.
    1. The working buttons allow you to go directly to the ending channel.
    2. You use the channel up button to go channel by channel up to the ending channel.
    3. You use the channel down button to go channel by channel down to the ending channel.
    4. You use the working buttons to go to the closest number that is higher than the ending channel and then use the channel down button repeatedly to get to the ending channel.
    5. You use the working buttons to go to the closest number that is lower than the ending channel and then use the channel up button repeatedly to get to the ending channel.
  7. You have to determine which of the options results in the minimum number of button pushes for a given starting and ending channel.
  8. After processing the input, display the minimum combination of buttons that will move the channel from the starting channel to the ending channel. Any combination of numbered buttons should be followed by the letter E to indicate the enter button. The channel up button is indicated by a number followed by the + character inside square brackets – [ ]. The channel down button is indicated by a number followed by the – character inside square brackets – [ ]. For example, the notation 56E[2+] indicates 56 was entered moving to channel 56 and the channel up button was entered twice moving to channel 58. The notation [56-] indicates the channel down button was pressed 56 times.
  9. Add comments at the top your source code file for your name and the problem number.
  10. The judges will enter additional test data not provided below to further test your application. You don’t need to validate the input. The judges will only enter valid data.
  11. Each set of data can be tested by rerunning the application.

Test Data

Starting ChannelEnding ChannelNumbered Buttons that workOutput
1222 6789 0 2 4 6 8 99 The smallest combination is 6800E[11-]
677 690 0 2 4 6 8 99 The smallest combination is 688E[2+]
9991 1050 4 5 7 99 The smallest combination is 777E[273+]
300 365 2 99 The smallest combination is [65+]
9998 5 2 8 99 The smallest combination is 2E[3+]
15 9996 0 1 2 99 The smallest combination is 1E[4-]

Want more info? Contact us.

Melinda White
Program Manager
Phone: 407.708.2447
Fax: 407.708.2322
Office: V102-I

Seminole State General Contact Information