As a follow up to my simulation based approximate solution to the Gambling Machine Puzzle, here is the exact solution from mathematician Michael Lugo with a nice explaination.
Originally posted on God plays dice:
An entrepreneur has devised a gambling machine that chooses two independent random variables x and y that are uniformly and independently distributed between 0 and 100. He plans to tell any customer the value of x and to ask him whether y > x or x > y.
If the customer guesses correctly, he is given y dollars. If x = y, he’s given y/2 dollars. And if he’s wrong about which is larger, he’s given nothing.
The entrepreneur plans to charge his customers $40 for the privilege of playing the game. Would you play?
Clearly the strategy is to guess that y > x if x is small, and to guess that y < x if x is large. Say you’re told x = 60. If you guess x is the larger variable, then conditional on your guess being correct (which has probability 0.6) you win an average of 30 dollars (halfway between 0 and 60). If your guess is incorrect you win nothing. Similarly, if you guess x is the smaller variable, then conditional on your guess being correct (which has probability 0.4) you win an average of 80 dollars (halfway between 60 and 100). So your expected winnings are 18 dollars if you guess x is the larger variable, and 32 if you guess x is the smaller variable. You should guess x is the smaller variable — that is, 60 is “small”.