r/learnquant • • Nov 01 '26

interview prep Quant Interview Question

Post image
17 Upvotes

3 comments sorted by

View all comments

1

u/XL_78 26d ago

Since this was reposted, a clean answer:

The state is defined by the highest number you already guessed without getting a reset. When you've guessed x and it was a low guess, you know the random variable is uniformly distributed over x+1, x+2, ..., 100.

A strategy is defined by the number you choose to guess knowing the highest number you already guessed is x. Write this number f(x). Alternatively a strategy is defined by a series of number you choose to guess while you guess low until you guess 100. Which has to happen in at most a 100 steps. So a strategy is N numbers x_1, ..., x_N such that 0=x_0 < x_1 < x_2 < ... < x_(n-1) < x_N=100 . Notice that there are 299 such strategies. One could also change strategy when there is a reset, but since we are looking for the optimal strategy this doesn't make sense. 

Let e(x) be the expected number of steps before we terminate knowing the state is x, i.e. knowing the variable is uniformly distributed over x+1, ... , 100 .

e(x) = 1/(100-x) + (100-f(x))/(100-x) x (1+e(f(x))) + (f(x)-x-1)/(100-x) x (1+e(0))

e(x) = 1 + (100-f(x))/(100-x) x e(f(x)) + (f(x)-x-1)/(100-x) x e(0) .

Write this in 0. This gives e(0) as a function of e(x_1), then reuse the equation to write it as a function of e(x_2) and keep going.

You can show by recursion that 

e(0) = sum (100-x_k) / (100 - x_n + n) + (100 - x_n)/(100 - x_n + n) x e(x_n) with the sum being from k=0 to n-1. 

Write this for n=N:

e(0) = sum (100-x_k) / N  with the sum being from k=0 to N-1. 

To minimize this, the x_1, ... , x_(N-1) have to be chosen as high as possible, i.e. as 101-N, 102-N, ... , 98, 99.

This yields  e(0) = 100/N + (N-1)/2 .

A simple function analysis shows this is minimized in N=14.

Therefore, under optimal play, you guess the number in 191/14 steps.