Suppose two players are playing a game. The first player chose an integer, n st. $n \in \left\{ 1,\ldots ,30\right\}$. The second player picks a different one. After that, a random integer x st. $x \in \left\{ 1,\ldots ,30\right\}$ will be generated. The player whose number is closer to $x$ gets paid $x$ dollars.

Q: Would you go first or second? What number should you pick?


5 Answers 5


Q: Would you go first or second?



There is a "middle number" splitting the values, so that no matter which side the second player picks as his winning numbers, the other side plus the middle number gives better expected value for the first player.

Q: What number should you pick?


The second player would then choose

21, because 23 would give him slightly worse EV.

Anyway, let's calculate the EV in both cases:

Since each number hits with equal probability, and the size of the win is equal to the winning number, summing each player's winning numbers gives an adequate way to compare the expected wins. (For the actual EV, divide each number by 30.)

If player 2 chooses 21:
* Player 1 wins on 22 to 30. 22+23+...+30=234
* Player 2 wins on 1 to 21. 1+2+...+21=231

If player 2 chooses 23:
* Player 1 wins on 1 to 22. 1+2+...+22=253
* Player 2 wins on 23 to 30. 23+24+...+30=212

After fixing the silly typo that caused my calculations to be wildly off, turns out my result is the same as JimSi's. Since his method, while definitely correct, is much more complicated than the one I used, I'm leaving this answer up too.

  • $\begingroup$ well done. Yes I wasn't sure if mine was right as it was an unnecessarily complicated method. How did you get the correct n, player 1 chooses. With your reasoning (second para, after the because), why does this not apply to the x is fixed case: where it does not matter who goes first, player 1 chooses 15, or 16, player 2 chooses other and have equal EV $\endgroup$
    – JimSi
    May 27, 2018 at 9:05
  • $\begingroup$ @JimSi, the first player’s strategy calls for choosing the (weighted) middle point. Since the weights are all known, I just kept adding them up until I reached half of the total weight. The number which caused the sum to cross from ”less than half” to ”more than half” contains the midpoint, and therefore is the first player’s choice. $\endgroup$
    – Bass
    May 27, 2018 at 17:10
  • $\begingroup$ Ok, yes that is a good strategy. Im just making the point that it does not necessarily give a better expected value for the first player, as you could employ the same strategy if pay out was fixed. $\endgroup$
    – JimSi
    May 27, 2018 at 18:01
  • $\begingroup$ Oh, and this doesn’t work in the unweighted case, because there are an even number of choices, so the midpoint falls between 15 and 16. $\endgroup$
    – Bass
    May 27, 2018 at 18:01
  • 1
    $\begingroup$ @JimSi, since we are on a puzzling site where we are allowed to play fast and loose with the maths, we could also cheat by applying a bit of calculus: since the growth of the values is linear, we know that the sum grows as a square. So without calculating too much anything, we know that we have reached half of the total sum for $\sum_{i=1}^{n} i$ just about exactly when we have counted up to $\frac{n}{\sqrt{2}}$, which becomes about $21.2$ when $n=30$. $\endgroup$
    – Bass
    May 28, 2018 at 10:41

My approach to this was probably not the best:

For a given n (that player 1 chooses), player 2 will choose n+1, or n-1.

I had four EVs:

$E_{1A}\left( X\right) $: for player 1 when player 2 chooses above— $n+1$, $E_{1B}\left( X\right)$: when player 2 chooses below, $n-1$, and $E_{2B}\left( X\right)$ and $E_{2B}\left( X\right)$ respectively.

So for example

$ E_{2B}\left( X\right) = \dfrac {n-1}{30}\times \dfrac {n}{2}=\dfrac {n^{2}-n}{60}$.

If player 1 chose n = 20 and player 2 chooses below i.e. 19, they have a 19/30 probability of being closer, multiplied by an average value of $\dfrac {19+1}{2}+1$

To want to go first, $E_{1A}\left( X\right)-E_{2A}\left( X\right) > 0$ and $E_{1B}\left( X\right) - E_{2B}\left( X\right)$ > 0, this only occurs when n = 22, so that is the answer I got, I feel like it was a long winded method.

  • 1
    $\begingroup$ Let others figure it out before you self-answer! It's not as fun to solve a puzzle when the solution is already given :) $\endgroup$
    – ffao
    May 27, 2018 at 6:33
  • $\begingroup$ @ffao, sorry, my thinking was that I am not sure mine is right, or a very good method, and I tried to hide it. But you are probably right, I might as well have waited, to see what other people come up with. $\endgroup$
    – JimSi
    May 27, 2018 at 9:06

It is not mentioned that if this game is going to be played like forever or once, but by wording I believe this is one time game, so you can only play this game only once. So the rest will be according to this assumption:

Let's say

Instead of $ \left\{ 1,\ldots ,30\right\}$, let's make it $ \left\{ 1,2,3 ,4\right\}$, so the first player optimal option will be obviously $3$. Because second player is forced to choose between $2$ and $4$. If he chooses $2$, he will win if the outcome is $1$ or $2$ (or 50% chance to win), if he chooses $4$, he can only win if outcome is $4$ (which is 25% chance to win). So the optimal choose will be $2$ if you want to increase his chance to win and but if he wants to maximize the expected value, he needs to go for $4$.

So, let's say the first players want to increase to chance to win instead of money;

The first player becomes advantageous with the higher expected value, $3\times0.25+4\times0.25=1.75$ whereas for second player it is $1\times0.25+2\times0.25=0.75$ and their chances to win the game is equal!

similarly, if the first players maximizes the expected value, he needs to go for

$4$ and the expected value of second player becomes $1$, whereas the first player's expectec value is $1.5$, which is $0.25$ is lower but the chance to win of first player was $50\%$ before, but now it is $75\%$!

So whatever the second player thinks to play, the first player will be


Let's make it

$\left\{ 1,2,3,4,5,6\right\}$ now, the player one will go for $5$ if he wants to optimize the expected value at the end but his chance to win will drop drastically compared to $ \left\{ 1,2,3 ,4\right\}$. He will naturally force to second player to go to $4$. and the $E(P1)=11$ points and $E(P2)=10$. But the chance to win the game for first player is only 33%, whereas second player has chance to win 66% which is as twice as first player. But statistically, for player 1, going for $5$ was the optimal by means of Expected Value, but what if he wants to win? he would go for $4$, so players two would go to $5$ and the chances to win would be reversed than before. Player 1 would have chance to win 66% whereas player 2 would have 33% chance to win with a little higher expected value than player 1.

Similarly, nothing would change much with $ \left\{ 1,\ldots ,30\right\}$, It actually depends on that

The question is, you want to win or you want to optimize/maximize your profit with highest expected value?

Think about it,

if this question was asked for 1 million dollars to 30 million dollars, you would think of winning the game or maximizing your expected value?


I believe there are two answers to this question depending on you would like to win or you would like to maximize your expected value, because you may even be okay with 1 million dollar to win? so it depends on the value of $30\$$ in your mind.

As a result,

Being first player is advantageous in general, because he/she can think of the expected value, chance to win, and the value of the winning the game for both sides and force the second player to play whatever he/she wants. For me, 30 dollars is not that much, so I would go for $22$ previously answered to maximize my expected value, but some other might think of going for $16$ to maximize his chance to win against the player who would think the same way.

  • $\begingroup$ Yes, agreed this is a good point!, there is no point having a high expected value with too high variance, $\endgroup$
    – JimSi
    May 29, 2018 at 20:49
  1. Say the first player picks the number $n$. How should the second player choose their number $m$?

    Their aim is to maximise the size of the set $$\{x:x\text{ is closer to $m$ than to $n$}\}$$ compared to the set $$\{x:x\text{ is closer to $n$ than to $m$}\}.$$ The cutoff point between these two sets is the point halfway between $m$ and $n$: in other words, the second player wants to make $\frac{m+n}{2}$ as close as possible to $n$. That means $m$ should be as close as possible to $n$, so the optimal choice is $m=n\pm1$.

    Whether the plus or minus sign is chosen depends on the value of $n$. The two sets displayed above will now be $\{x>n\}$ and $\{x\leq n\}$ respectively if $m>n$, or $\{x<n\}$ and $\{x\geq n\}$ respectively if $m<n$.

    So the second player's strategy is:

    choose $m=n+1$ if $n\leq15$, or $m=n-1$ if $n\geq16$.

  2. Given the above, what number $n$ should the first player choose?

    WLOG, we can assume $n\leq15$ (otherwise, replace $n$ and $m$ by $30-n$ and $30-m$ and use the same logic). Then we have $m=n+1$, and the second player's chance of winning is $\frac{30-n}{30}$ while the first player's chance is $\frac{n}{30}$. So to maximise their chance, the first player should choose $n=15$.

    So by symmetry, the optimal choice is

    either $n=15$ or $n=16$.

With both players playing optimally, their chances of winning are

exactly half each.

  • $\begingroup$ I feel like this is the answer if what you get paid is fixed? if the integer is 30, and you are closer you get 30 $\endgroup$
    – JimSi
    May 26, 2018 at 16:34
  • $\begingroup$ See my attempted answer, I don't know how to hide parts of it so will try and do that $\endgroup$
    – JimSi
    May 26, 2018 at 16:38
  • $\begingroup$ @Jaap Scherphuis, yes the x is random, but ok, say if Player 1 chooses 16, player 2 would gain by choosing 17, as his expected pay out would be 14/30 *(a way higher average value than player 1 could get) 14/30 * (23.5) = 10.96, rather than player 1 who gets 16/30*8.5 = 4.53 $\endgroup$
    – JimSi
    May 26, 2018 at 16:45
  • $\begingroup$ @Jim Damn, I misread the problem! Sorry :-( $\endgroup$ May 26, 2018 at 16:47
  • $\begingroup$ sorry you wrote out that answer, when I saw this question I thought that, I tried to make it clearer with the bold. $\endgroup$
    – JimSi
    May 26, 2018 at 16:49

If Player 1 chooses a number under 16, 2 can just choose $n+1$, as that way he'll win for any $x$ value over 1's number $n$ (from 16 at most to 30), and win more on average.

If 1 picks one over 15, it becomes more complicated in that 2 must also make sure he gets the best expected result besides just winning. Among the numbers below $n$, the best option would be $n-1$, which gives the expected result $(n-1)n/60 = (n^2-n)/60$. If 2 is going to pick a number above $n$, $n+1$ is his best bet, which gives $(n+31)(30-n)/60 = (930-n^2-n)/60$. So, if $n^2>465$ ($n>21$), 2 must pick $n-1$, otherwise $n+1$.

That means if $n>21$, 1's expected value is $(n+30)(31-n)/60 = (930-n^2+ n)/60$ and 2's is $(n^2-n)/60$ with the former ONLY exceeding the latter if $n=22$. If $n<22$, 1's expected value is $(n^2+n)/60$ and 2's is $(n+31)(30-n)/60 = (930-n^2-n)/60$ with the latter always exceeding the former, so you can only guarantee winning more than a perfect opponent if you're first and you pick 22.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.