fork download
  1. from random import randint, choice
  2.  
  3. successes, attempts = 0, 0
  4.  
  5. while attempts < 1000:
  6. correct_door = randint(0, 2)
  7. players_door = randint(0, 2)
  8. unchosen_losing_doors = [ x for x in [0,1,2] if x != correct_door and x != players_door ]
  9. opened_door = choice(unchosen_losing_doors)
  10. door_to_which_we_switch = 3 - players_door - opened_door
  11. attempts += 1
  12. if correct_door == door_to_which_we_switch: successes += 1
  13.  
  14. print(successes)
Success #stdin #stdout 0.11s 14392KB
stdin
Standard input is empty
stdout
678