## unknown Interview Question

Data Scientists**Country:**United States

You can just do the math, there's a way to tidy it up, but to map out playing through, you get

Pay first time, you win 25% of the time and get better odds 75% of the time

Pay second time, you win 33.33% of the time and get better odds 66.66%

...

P1 = (1/4) * 100 + (3/4) * P2 - x

P2 = (1/3) * 100 + (2/3) * P3 - x

P3 = (1/2) * 100 + (1/2) * P4 - x

P4 = 100 - x

Substituting these, setting to 0 and solving for x you get 40.

To see it with the numbers:

Case of play once and pay 25, you get:

1/4 times you get 75

3/4 times you get -25

With replays and paying 40, you get:

1/4 times you get 60

1/4 times you get 20

1/4 times you get -20

1/4 times you get -60

Agree with your answer but there's a simpler way to see it.

E[cost] = (1/4) * x + (1/4) * 2x + (1/4) * 3x + (1/4) * 4x = (5/2)x

The above is simply a translation of expected value definition, assuming we keep going until we win (*not* assuming this leads to a more complex problem, would probably be a fun discussion with an interviewer). And we can immediately see we want x <= 2/5 * box value to get cost <= box value

2.5x

mean= x*probablity(first time he get 100 one)=x/4 + (2x)*probablity(first time he didn= not get but got second time) =2x*3/4*1/3=2x/4 + (3x)* probabality(not getting first two time and then getting)= 3x*3/4*2/3*1/2=3x/4 + (4x)*probabality(getting it finally)=4x*3/4*2/3*1/2*1=4x/4

s0 x/4+2x/4+3x/4+4x/4=2.5x

4x

- v January 31, 2019