# Problem 52323. Guess the number I'm thinking of (Part 2)

Have you tried the original "Guess the number I'm thinking of" (Problem 44630)? This problem is just like that, except that the range of possible numbers can change, and pre-calculated answers are explicitly disallowed. Computing all possible permutations on the fly is not disallowed per se, but it is discouraged due to the high computational load involved.
In this game you are competing against two other people to guess the number that I'm thinking of.
1. I randomly choose an integer between one and N (inclusive). N is an integer between 4 and 1000 (inclusive) that will be specified in each test as upperLimit. I don't provide any other clues about the number that is to be guessed.
2. Your first opponent tries to guess the number. They guess randomly.
3. Your second opponent tries to guess the number. They also guess randomly.
4. You try to guess the number. But you guess strategically.
5. The winner is the person who guesses my chosen number, or the person who guesses closest to my chosen number. This represents a "win".
6. If two contestants are equally close, they may share the win, with such a result being declared a "draw". (It is a loss for the remaining contestant.) A draw is worth half as much as a win.
Each person hears the guesses stated by any preceding competitors, so you will be aware of the two prior guesses (provided to you as the vector guessesOfOpponents). Moreover, each guess must be unique.
If everyone guessed randomly, each person should have an equal chance of winning.
It might seem that you're at a disadvantage, having the last opportunity to guess. But actually you have the advantage of extra knowledge.
By guessing strategically, you should be able to achieve a "success rate" of substantially better than 33.3%. The success rate is defined as follows.
success rate = (wins + draws/2) / games
The precise value of the expected success rate (when guessing with the optimal strategy) depends upon the value of N: when N = 4 you should be able to achieve a success rate of 17/48 ≈ 35.4% on average, increasing monotonically to above 50% for N ≥ 24, eventually approaching an asymptote of 19/36 ≈ 52.8%. (See the Test Suite for details of the thresholds applied.)
RELATED PROBLEM:

### Solution Stats

8.93% Correct | 91.07% Incorrect
Last Solution submitted on May 13, 2022

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!