You will count the cases of the game with doors exactly. The prize is behind one door chosen at random. The player always picks door . The host opens all the other doors except one, never opens the prize door, and leaves one door closed besides the player's door. The checker tests , and doors.
The idea. If the prize is not behind the player's door, the host must leave the prize door closed. If the prize is behind the player's door, the host leaves any one of the other doors closed, each equally likely. Switching wins when the closed door holds the prize.
Your tasks.
closed_door_choices(prize, n). Return the list of doors that the host may leave closed besides door .p_stay(n). Add for each position of the prize that equals the player's door.p_switch(n). For each position of the prize, add times the fraction of the host's choices that equal the prize.Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…