In a casino, a popular game is played on a device called a slot machine. In the game, 3 wheels
have symbols around them. The wheels spin, and each randomly stops on a
symbol. When the three symbols on which each wheel lands match, the player wins. It costs one coin
for each play of the game. The number of coins the player wins when landing on a winning combination
is determined by a payout chart shown below.
Although they do not affect the outcome of the game, the player can typically see which symbol
is immediately above and below the symbol on which each wheel stopped. The frequency of different
symbols appearing on each different wheel, and indeed, on each different machine, may vary. An
example of what is visible after playing is shown below:
B - C - E
-- D - D - D --
F - A - C
Each column is the three symbols shown on a given wheel. The middle row is the "pay line", that
is to say, the symbols that must match to win a prize. Indeed the result of the spin shown above
is a winner. The output of the spin could be described as "BCEDDDFAC", where B-D-F are consecutive
symbols on the first wheel, C-D-A are consecutive symbols on the second wheel, and E-D-C are
consecutive symbols on the third wheel.
Some friends have informed you that at a particular casino, some of the slot machines may be
"broken" in a sense that the frequency of symbols on the wheels is such that the player may tend
to win more coins than they will lose. You have only a limited amount of time to mess around, as
of course you have important meetings to attend, however, you figure it might be worth a look into
Playing a slot machine without paying much attention to the specific outcome (beyond how many
coins you may have won) takes a single unit of time, whereas playing in such a way
that you make an effort to note down the symbols that show up takes much longer. You will initially
be given startingCoins, maxTime, noteTime, and numMachines.
The payout table looks the same for all of the slot machines:
A A A : 1,000
B B B : 200
C C C : 100
D D D : 50
E E E : 20
F F F : 10
G G G : 5
Your code may call one of two library methods:
- PlaySlots.quickPlay(machineNumber, times): returns the total number of coins you won by
playing times times on machineNumber.
- PlaySlots.notePlay(machineNumber, times): returns a String where the first
element is the number of coins you won (converted to a String), and each additional
element is the nine symbols shown on a given play
In either case, you the number of times you play cannot be more than the number of coins
you currently hold, as you cannot depend upon unknown winnings to keep playing.
Test case generation is done as follows (all selections are uniformly at random):
- coins is chosen between 100 and 10000
- maxTime is chosen between 100 and 10000
- noteTime is chosen between 2 and 10
- numMachines is chosen between 3 and 10
- The wheel size is chosen (separately for each machine) between 10 and 30
- Each symbol on each wheel is chosen from the distribution "AABBBBCCCCCDDDDDDEEEEEEFFFFFFFGGGGGGGG"
The time limit per test case is 30s, and the memory limit is 1GB. Any calls with invalid parameters,
any exceptions thrown by competitor code, and so on, will result in failing that test case (and getting no points
towards the final score).
You may play as few or as many times as you like, so long as you don't run out of coins or time.
Your raw score for a test case will be the total number of coins you have at the end of all your
playing. Your relative score for a given test case will be YOURS / MAX, where MAX is the highest
score anyone achieved for a test case. Your total combined score will be 1,000,000 * SUM(REL_SCORE).
You can download the test harness code that is used internally, for reference, to understand
test case generation, or for general clarity on how the processing works.
For reference, we are also providing a skeletal solution in Java, C++, C# and Python.