Programming Problem #42
"You Can't Beat the House"

"Craps" is a dice game played in most casinos. It is played with two six-sided dice, each with sides numbered from 1 to 6. Rolling both dice yields a number between 2 and 12 inclusive. The game is played as follows. Both dice are thrown. If the result is a 2, 3, or 12, the player loses immediately. If the result is a 7 or 11, the player wins immediately. Any other result is called the point, and the player must continue to roll both dice until the point is rolled again (in which case the player wins) or a 7 is rolled (in which case the player loses).

Like all casino games, the odds favor the casino. In other words, in the long run a player will lose more often than win. Compute the odds that a player will lose via simulation as follows: play 1000 random games and compute the losing percentage p. Then continue to play random games, updating p after each game, until two successive games yield values of p that differ by at most 0.0005 percent. Display the result in the format xx.xxx%.

This problem has no input file. Output must be written to the file prob42.out. All output to the screen will be ignored.

Example Input

(none)

Example Output

(you wish!)

Dr. Eric Shade