You are on page 1of 2

Prescreening Exercise - Level 11 - Senior Application Developer

Time Limit
You have 1 hour to complete this game.

Instructions
Please read the instructions carefully and submit a solution to the task described below.

You can use notepad, or your code editor of choice (i.e. Notepad++ VS Code, etc.) to build your
solution. Once complete, save your code to a text file and save it under your name on the flash drive
provided. You are free to access resources on the internet to assist with the design of your solution.
Note that any plagiarism of similar tests / solutions will result in a fail.

Task

Design the code for a solution that satisfies the criteria given below. Design your solution to show
solid programming technique including functions, and reusable code where applicable. Demonstrating
problem solving skills and solid design are more important than the coding language used. You may
use C#, pseudo code or a combination of the two.

Game

Description

In front of you is a row of 6 coins, with random values between 1 and 100.

You are asked to play the following game. You and an opponent take turns choosing either the first or
last coin from the row, removing it from the row, and receiving the value of the coin.

** Assume that both players always take the coin with the highest value.
** Coin values can repeat, if the coins are equal value then the first coin in the row is taken.

Examples:
{ 99, 9, 4, 33, 25, 11 } returns 133

{ 5, 1, 10, 5, 5, 5 } returns 20

{ 10, 5, 25, 5, 10, 25 } returns 60


 Write a program that returns the maximum amount of points you can win with certainty, if you
move first, assuming you and your opponent always pick the highest coin.

 Add to your program the ability to simulate the game over 10 iterations and keep a count of the
final score for each game. Each game should generate a random set of coins, simulate the game
and output the points for the first player.

 Include in your program the functions and classes required to:


o calculate the points you earn for each game
o simulate the game 10 times
o output the results as shown below

The output would look something like this:


For the set of coins 5, 63, 91, 65, 87, 94. You earned 222 points in game 1
For the set of coins 42, 99, 43, 24, 77, 70. You earned 155 points in game 2
For the set of coins 56, 71, 13, 87, 94, 37. You earned 180 points in game 3
For the set of coins 59, 85, 42, 13, 47, 40. You earned 148 points in game 4
For the set of coins 78, 22, 31, 21, 70, 18. You earned 179 points in game 5
For the set of coins 3, 24, 11, 42, 61, 12. You earned 78 points in game 6
For the set of coins 46, 68, 46, 89, 6, 21. You earned 113 points in game 7
For the set of coins 12, 87, 30, 80, 12, 34. You earned 201 points in game 8
For the set of coins 66, 28, 41, 54, 28, 29. You earned 148 points in game 9
For the set of coins 53, 21, 32, 21, 6, 90. You earned 132 points in game 10

You might also like