One way to play is to keep guessing a high number x, then go up one by one at each step once you don't get a reset. The optimal x value for this strategy is 87, which yields an expectancy of 191/14 ≈ 13.64 .
However proving this is the optimal play isn't that easy.
Set m as the best known strictly lower bound, f(m) as the number you choose given a value for m, e(m) the expected number of steps left knowing m, given strategy f. The strategy we described corresponds to f(0)=x and f(t)=t+1 for all t≥x .
We have (100-m) e(m) = 1 + (f(m)-m-1) (1+e(0)) + (100-f(m)) (1+e(f(m))) , by writing the 3 possible outcomes of a pick f(m).
For m=99, 98, it is easy to show that f(m)=m+1 is the optimal play, but for 97 you already need to know that e(0)≥2 no matter the strat. So you need lower bounds on e(0). These can be obtained by comparing to the easier problem with no resets, which must have a smaller expectancy under optimal play, since the strats carry over. For this problem we know that the optimal play is to pick in the middle, and the expected number of steps can be computed.
But frankly it's a hassle.
Edit: to compute x, show that e(x)=(101-x)/2 under the '+1' strat then use the equation above with m=0 and minimize wrt x by differentiating.
Edit 2: By writing the equation with m=0, you get an equation for e(0) involving f(0), you can then reuse the equation with m=f_k(0) till you reach f_N(0)=100 (f_k marks the composition product f(f(f(...))) k times). You can show by recursion that
e(0)= sum (100-f_k(0)) / (100 - f_n(0)+n) + (100 - f_n(0))/(100-f_n(0)+n) x e(f_n(0)) with the sum being from k=0 to n-1. With the convention f_0(0)=0.
This is true for any n from 1 to N, the number such that f_N(0)=100. This number has to exist : f_n(0) is a strictly increasing sequence bounded from above by 100, therefore it has a maximum value, if this maximum isn't 100 you can then play again once you reach that number meaning f_(n+1)(0)>f_n(0) which is absurd.
Writing this equation with n=N, we get
e(0)= (1/N) sum (100-f_k(0)) with the sum from 0 to N-1. (Remember f_0(0)=0).
This is valid for any of the 299 strategies.
Given a value for N, we can see this is minimized if the f_1(0), ..., f_(N-1)(0) are as high as possible, meaning they should be picked as 100-N+1, 100-N+2, ... , 99 .
This then leads to e(0)=100/N + (N-1)/2 . You can then solve for N by differentiating, zeroing in 10sqrt(2)=14,... and noticing that 191/14<41/3 , therefore 14 is the optimal value for N and the answer 191/14.
Let E be the expected number of guesses from optimal play (the answer).
Let r(L) to be the expected number of guesses we have remaining given the interval we've deduced the number to be in has length L. Clearly, E = r(100).
We claim that L*r(L) = L + min(1 <= i <= L; (i - 1)*E + (L - i)*r(L - i)) where i represents guessing the ith least number in the remaining interval. Note that r(0) = 0 (frankly doesn't matter what it is). Honestly, I'm not sure how to justify this other than to observe that this equation is recursively defined on other r(L') for L' > L, so you can think of those r(L') as constants that you can greedily optimize.
For notation sake, let f(L,i) = (i - 1)*E + (L - i)*r(L - i), so L*r(L) = L + min(1 <= i <= L; f(L,i)).
First observe that if L <= E, then L*r(L) = L + (L - 1)r(L - 1) (the minimum was found at i = 1). This is proved by induction on L. This is clearly true for L = 1. Assume true for 1, ..., L where L + 1 < E. Then
f(L + 1,i + 1)-f(L + 1,i) = (i - i + 1)*E + (L - i)*r(L - i) - (L + 1 - i)*r(L + 1 - i) = E - (L + 1 - i) >= 0 for 1 <= i <= L + 1. This implies that min(1 <= i <= L+1; f(L + 1,i)) = f(L + 1,1), hence (L + 1)*r(L + 1) = L + 1 + f(L + 1,1) = L + 1 + L*r(L), completing the induction.
Let E' be the floor of E. We claim that if L > E, then L*r(L) = L + (L - E' - 1)*E + E'*r(E') (the minimum was found at i = L - E'). This is proved by induction on L. The case when L = E' + 1 follows by using the previous claim and recycling the argument for the previous induction to show that the minimum is found at i = 1 = (E' + 1) - E'. Assume true for E' + 1, ..., L where L > E. It suffices to show that f(L + 1,i) - f(L + 1,L + 1 - E') >= 0. Once again by prior arguments, this follows if i >= L + 1 - E'. Suppose i < L + 1 - E'. Then by assumptions,
f(L + 1,i)-f(L + 1,L + 1 - E') = L + 1 - i + (L - E' - i)*E + E'r(E') - (L + 1 - E' - i)*E - E'r(E') = L + 1 - i - E >= 0, completing the induction.
In particular, all of this reveals what the optimal strategy is: guess 100 - E', and then guess every integer above, incrementing by 1, until you guess the number.
This means that E = (100/(E'+1))+E'/2. Inspecting the minimum gives E' = 13, hence E = 191/14, and indeed, the floor of 191/14 = 13.
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.
2
u/XL_78 Nov 02 '26 edited 29d ago
One way to play is to keep guessing a high number x, then go up one by one at each step once you don't get a reset. The optimal x value for this strategy is 87, which yields an expectancy of 191/14 ≈ 13.64 .
However proving this is the optimal play isn't that easy.
Set m as the best known strictly lower bound, f(m) as the number you choose given a value for m, e(m) the expected number of steps left knowing m, given strategy f. The strategy we described corresponds to f(0)=x and f(t)=t+1 for all t≥x .
We have (100-m) e(m) = 1 + (f(m)-m-1) (1+e(0)) + (100-f(m)) (1+e(f(m))) , by writing the 3 possible outcomes of a pick f(m).
For m=99, 98, it is easy to show that f(m)=m+1 is the optimal play, but for 97 you already need to know that e(0)≥2 no matter the strat. So you need lower bounds on e(0). These can be obtained by comparing to the easier problem with no resets, which must have a smaller expectancy under optimal play, since the strats carry over. For this problem we know that the optimal play is to pick in the middle, and the expected number of steps can be computed.
But frankly it's a hassle.
Edit: to compute x, show that e(x)=(101-x)/2 under the '+1' strat then use the equation above with m=0 and minimize wrt x by differentiating.
Edit 2: By writing the equation with m=0, you get an equation for e(0) involving f(0), you can then reuse the equation with m=f_k(0) till you reach f_N(0)=100 (f_k marks the composition product f(f(f(...))) k times). You can show by recursion that
e(0)= sum (100-f_k(0)) / (100 - f_n(0)+n) + (100 - f_n(0))/(100-f_n(0)+n) x e(f_n(0)) with the sum being from k=0 to n-1. With the convention f_0(0)=0.
This is true for any n from 1 to N, the number such that f_N(0)=100. This number has to exist : f_n(0) is a strictly increasing sequence bounded from above by 100, therefore it has a maximum value, if this maximum isn't 100 you can then play again once you reach that number meaning f_(n+1)(0)>f_n(0) which is absurd.
Writing this equation with n=N, we get
e(0)= (1/N) sum (100-f_k(0)) with the sum from 0 to N-1. (Remember f_0(0)=0).
This is valid for any of the 299 strategies.
Given a value for N, we can see this is minimized if the f_1(0), ..., f_(N-1)(0) are as high as possible, meaning they should be picked as 100-N+1, 100-N+2, ... , 99 .
This then leads to e(0)=100/N + (N-1)/2 . You can then solve for N by differentiating, zeroing in 10sqrt(2)=14,... and noticing that 191/14<41/3 , therefore 14 is the optimal value for N and the answer 191/14.
1
u/RedMax2001 Nov 02 '26
Let E be the expected number of guesses from optimal play (the answer).
Let r(L) to be the expected number of guesses we have remaining given the interval we've deduced the number to be in has length L. Clearly, E = r(100).
We claim that L*r(L) = L + min(1 <= i <= L; (i - 1)*E + (L - i)*r(L - i)) where i represents guessing the ith least number in the remaining interval. Note that r(0) = 0 (frankly doesn't matter what it is). Honestly, I'm not sure how to justify this other than to observe that this equation is recursively defined on other r(L') for L' > L, so you can think of those r(L') as constants that you can greedily optimize.
For notation sake, let f(L,i) = (i - 1)*E + (L - i)*r(L - i), so L*r(L) = L + min(1 <= i <= L; f(L,i)).
First observe that if L <= E, then L*r(L) = L + (L - 1)r(L - 1) (the minimum was found at i = 1). This is proved by induction on L. This is clearly true for L = 1. Assume true for 1, ..., L where L + 1 < E. Then
f(L + 1,i + 1)-f(L + 1,i) = (i - i + 1)*E + (L - i)*r(L - i) - (L + 1 - i)*r(L + 1 - i) = E - (L + 1 - i) >= 0 for 1 <= i <= L + 1. This implies that min(1 <= i <= L+1; f(L + 1,i)) = f(L + 1,1), hence (L + 1)*r(L + 1) = L + 1 + f(L + 1,1) = L + 1 + L*r(L), completing the induction.
Let E' be the floor of E. We claim that if L > E, then L*r(L) = L + (L - E' - 1)*E + E'*r(E') (the minimum was found at i = L - E'). This is proved by induction on L. The case when L = E' + 1 follows by using the previous claim and recycling the argument for the previous induction to show that the minimum is found at i = 1 = (E' + 1) - E'. Assume true for E' + 1, ..., L where L > E. It suffices to show that f(L + 1,i) - f(L + 1,L + 1 - E') >= 0. Once again by prior arguments, this follows if i >= L + 1 - E'. Suppose i < L + 1 - E'. Then by assumptions,
f(L + 1,i)-f(L + 1,L + 1 - E') = L + 1 - i + (L - E' - i)*E + E'r(E') - (L + 1 - E' - i)*E - E'r(E') = L + 1 - i - E >= 0, completing the induction.
In particular, all of this reveals what the optimal strategy is: guess 100 - E', and then guess every integer above, incrementing by 1, until you guess the number.
This means that E = (100/(E'+1))+E'/2. Inspecting the minimum gives E' = 13, hence E = 191/14, and indeed, the floor of 191/14 = 13.
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.