Q5
Q5
Let's say there is a game that is fair and that two players, Player A and Player B, are
competing against each other.
The person who wins the first (m+1)/2 games out of a maximum of m odd games is
declared the champion.
Let's say you have x rupees to invest and want to place a bet on player A. You may
bet an amount of y in each game, where y is either equal to or less than x.
You will receive double your initial bet for each game that Player A wins, or nothing
at all if the player loses.
Unfortunately, betting is limited to individual games and not available for the entire
series.
Condition:
The amounts that was bet in each game are in a manner such that if the Player A
wins the whole championship, you will win exactly x and if player A loses the
championship you lose exactly x.
Question 1:
Create the optimal_amount(m,x) function, which takes in the following parameters:
m indicates the maximum number of championship games that can be played.
The variable x which represents the total amount that can be deployed in the entire
championship.
For any possible scenario which can be lead to the above case, the function should
return a list:
List1: Boolean list that represents whether Player A won that match or not.
List2: Amount that was bet in each game
Example Input: 3 100
Example Output: [0, 1, 1] [50, 50, 100]
Explanation:
IF we had total 3 games in championship and Player A won the last two games.
List1 is [0, 1, 1 ]
List2 is [50, 50,100]
Question 2:
Create the optimal_amount_given_state(m,x,p1,p2,y) function, which takes in the
following parameters:
m indicates the maximum number of championship games that can be played.
The variable x which represents the total amount that can be deployed in the entire
championship.
p1 and p2 tell the number of matches that have been won by playerA and playerB
respectively till now.
Y is the money that was bet in the last game
For any possible scenario which can be lead to the above case, the function should
return the amount that should be bet in next game:
Example Input: 3 100 0 1 50
Example Output: 50
Explanation:
IF we had total 3 games in championship and Player A won the last two games.
List1 is [0, 1, 1 ]
List2 is [50, 50,100]
So since the given state was (0,1) and he had bet 50 in last game . He has to bet 50
in next game.
Submission Format
Three files are expected from you put together in a .zip file, for it to be qualified as a
valid submission. See details for the files and their extensions. Please ensure that
these files are actually zipped directly, and not any folder which contain these files.
1. Python code in a file with .py extension
A python file containing the above two functions. A sample python file with the format
has been provided to you as Q5.py, you need to fill your logic in the function
optimal_amount and optimal_amount_given_state.
State Amount
0 50
1 50
1 100
The second csv would contain only one entry for the amount to be invested in the
next round to meet the above constraints.
A sample csv names samplesubmission2.csv is provided for reference. This csv
should be generated from the code itself. Example for the explained example the
dataframe would look this.
Amount
50
Put the files in a zip and upload the zip file. Do note that you need not put the files in
a folder when zipping.
Evaluation Criteria
We shall measure submissions on the criteria:
Run the results submitted for problems to see if it passed the above mentioned
conditions.
Primarily we shall use the prediction file provided for test to form a cutoff.
We shall use extra out-of-sample data not provided to you for final scoring.