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
Solution Comments
Show comments
Loading...
Problem Recent Solvers67
Suggested Problems
-
Which values occur exactly three times?
5234 Solvers
-
Replace NaNs with the number that appears to its left in the row.
3059 Solvers
-
23624 Solvers
-
Determine if input is a perfect number
258 Solvers
-
1116 Solvers
More from this Author32
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
In some cases, it would be strategically beneficial to guess the same number as one of your opponents. For example, if they guess 7 and 9, for example, you would generally earn more points guessing 7 than any other number, as you would earn an extra half point from the draw if the number is 7 or 8 (which is a three-way draw) and not lose any of the full points if the number is 1-6.
Hi, James. That may be a valid point ...when playing with different rules. I deliberately set the constraint that all three guesses (from the three contestants) must be different. If my constraint were removed, then you would have freedom to implement that strategy; it would also mean you'd have to handle the situation of your opponents choosing the same number. However, I personally would not be scoring a three-way draw the same as a two-way draw. Consider if each person pays $1 into a 'prize pool' to enter: if you achieve a two-way draw, then you get back $1.50 (a 50¢ profit); but in a three-way draw nobody would get any profit, and hence I would be scoring it as if that 'game' never happened. —DIV
Understood, and I agree that a three-way draw (not possible with the current rule set) should definitely be scored differently than a two-way draw.
My code worked, although not quite as well as Tim's. I'll have to check the algorithms he used to generate his solution, and see how it differs from mine.
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.
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.
Thanks. There are indeed some more that I have thought of like this....