Monty Hall problem: Difference between revisions
Content added Content deleted
Line 943: | Line 943: | ||
=={{header|PureBasic}}== |
=={{header|PureBasic}}== |
||
<lang PureBasic> |
<lang PureBasic>Procedure MontyHall(Redecide) |
||
Procedure MontyHall(Redecide) |
|||
Dim Doors(2) |
Dim Doors(2) |
||
Doors(Random(2)) = 1 |
Doors(Random(2)) = 1 |
||
Line 952: | Line 951: | ||
Open = 1 |
Open = 1 |
||
EndIf |
EndIf |
||
Pick = Redecide-Open |
|||
Pick = 1-Open |
|||
EndIf |
|||
Debug pick |
|||
ProcedureReturn Doors(Pick) |
ProcedureReturn Doors(Pick) |
||
EndProcedure |
EndProcedure |
||
Line 973: | Line 969: | ||
PrintN("Wins when redeciding: " + Str(Win1) + " (" + StrD(Win1/#Tries*100, 2) + "% chance)") |
PrintN("Wins when redeciding: " + Str(Win1) + " (" + StrD(Win1/#Tries*100, 2) + "% chance)") |
||
PrintN("Wins when sticking: " + Str(Win2) + " (" + StrD(Win2/#Tries*100, 2) + "% chance)") |
PrintN("Wins when sticking: " + Str(Win2) + " (" + StrD(Win2/#Tries*100, 2) + "% chance)") |
||
Input() |
Input() |
||
</lang> |
|||
Output:<pre>Trial runs for each option: 1000000 |
Output:<pre>Trial runs for each option: 1000000 |