Problem 44630. Guess the number I'm thinking of (Part 1)
Solution Stats
Problem Comments

6 Comments
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 threeway draw) and not lose any of the full points if the number is 16.
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 threeway draw the same as a twoway draw. Consider if each person pays $1 into a 'prize pool' to enter: if you achieve a twoway draw, then you get back $1.50 (a 50¢ profit); but in a threeway 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 threeway draw (not possible with the current rule set) should definitely be scored differently than a twoway 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 suboptimal.
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....
Solution Comments

2 Comments
This is a perfect example of how bad the Cody scoring system is. Kudos to Binbin Qi for figuring out how to minimize the score, but it shouldn't be necessary to obfuscate a straightforward solution.
I agree.

1 Comment
An elegantly simple solution.

2 Comments
This one is a little shorter, but also longer.
Ah. Now I understand why your approach was guaranteed yield the strategically most effective guesses!

1 Comment
Well done! You actually devised a marginally more efficient strategy than my reference solution. :) I've tweaked my reference solution to try to match your outputs, which makes me think that you could most likely reduce the size of your submission (if you were so inclined).

1 Comment
By my reading, this is close to a correct solution. The second half looks OK, but I think you may need to tweak some code in the first half.
Problem Recent Solvers34
Suggested Problems

4692 Solvers

We love vectorized solutions. Problem 1 : remove the row average.
660 Solvers

Is this triangle rightangled?
3759 Solvers

320 Solvers

262 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!