Problem 44630. Guess the number I'm thinking of (Part 1)
In this game you are competing against two other people to guess the number that I'm thinking of.
- I randomly choose an integer between one and ten (inclusive). I don't provide any clues about the number.
- Your first opponent tries to guess the number. They guess randomly.
- Your second opponent tries to guess the number. They also guess randomly.
- You try to guess the number. But you guess strategically.
- The winner is the person who guesses my chosen number, or the person who guesses closest to my chosen number. This represents a "win".
- 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 45% or more, in which
success rate = (wins + draws/2) / games
RELATED PROBLEM:
Solution Stats
Problem Comments
-
6 Comments
Show
3 older comments
James
on 16 May 2018
I figured out why Tim's solution scored higher than mine. My code gave me half credit for a few oddball cases where there was a tie between two of us but the third person was closer to the correct number. It didn't happen enough for the solution to fail the tests, but it was still sub-optimal.
goc3
on 16 Jul 2018
This is a great problem. I was planning to eventually do one like this, but now I don't have to, as this one is very well implemented.
By the way, more problems like this one would be great, too.
David Verrelli
on 17 Jul 2018
Thanks. There are indeed some more that I have thought of like this....
Solution Comments
Show commentsGroup

Number Manipulation III
- 15 Problems
- 14 Finishers
- High Precision Square Root (Inspired by Project Euler 80)
- Damping of Servomotors with Tachometer Feedback
- Find the right number make the equation
- Deriving a function using the difference quotient
- Fast 1-D Convolution (full shape)
- Fast 1-D Convolution (same shape)
- Fast 1-D Convolution (valid shape)
- Lambert's W
- First use of arrayfun() and anonymous function @(x)
- Cell Operator *
- Product of two multivariate polynomials
- Multivariate polynomials - convert monomial form to array
- Multivariate polynomials - overload multiplication
- Multivariate polynomials - emulate symbolic form
- Rewrite setdiff to account for non-unique values
Problem Recent Solvers50
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!