Monty Hall problem: Difference between revisions

Content added Content deleted
Line 943: Line 943:


=={{header|PureBasic}}==
=={{header|PureBasic}}==
<lang PureBasic>Procedure MontyHall(Redecide)
<lang PureBasic>
Procedure MontyHall(Redecide)
Static Dim Doors(2)
Doors(0) = 0
Dim Doors(2)
Doors(1) = 0
Doors(2) = 0
Doors(Random(2)) = 1
Doors(Random(2)) = 1
Pick = 2
Pick = 2
Line 962: Line 960:


OpenConsole()
OpenConsole()
#Tries = 10000000
#Tries = 1000000
For I = 0 To #Tries
For I = 0 To #Tries
Win1 + MontyHall(1)
Win1 + MontyHall(1)
Line 977: Line 975:
Input()</lang>
Input()</lang>


Output:<pre>
Output:<pre>Trial runs for each option: 1000000
Wins when redeciding: 666425 (66.64% chance)
Trial runs for each option: 10000000
Wins when redeciding: 6663398 (66.63% chance)
Wins when sticking: 331930 (33.19% chance)</pre>
Wins when sticking: 3332060 (33.32% chance)</pre>


=={{header|Python}}==
=={{header|Python}}==