30 lines
713 B
Python
30 lines
713 B
Python
from random import shuffle, randint
|
|
|
|
result = { "swap": 0, "not_swap": 0 }
|
|
|
|
doors = [ 0, 0, 1]
|
|
door_indices = list(range(3))
|
|
|
|
for i in range(500):
|
|
shuffle(doors)
|
|
shuffle(door_indices)
|
|
door_chosen, door_opened, door_swap = door_indices
|
|
if doors[door_opened] == 1:
|
|
door_swap, door_opened = door_opened, door_swap
|
|
|
|
if doors[door_swap] == 1:
|
|
result["swap"] += 1
|
|
elif doors[door_chosen] == 1:
|
|
result["not_swap"] += 1
|
|
else:
|
|
print("WTF?")
|
|
break
|
|
|
|
p100 = result["swap"] + result["not_swap"]
|
|
|
|
p_swap = result["swap"]*100/p100
|
|
|
|
p_not_swap = result["not_swap"]*100/p100
|
|
|
|
print("Swap door\t: %.2f%%" % p_swap)
|
|
print("Don't swap door\t: %.2f%%" % p_not_swap)
|