Monty Hall problem: Difference between revisions

code entered
(added Liberty BASIC)
(code entered)
Line 1,697:
print(player.wins)
end</lang>
 
=={{header|Mathematica}}==
 
<lang Mathematica>
 
montyHall[g_] :=
Module[{r, winningDoors, firstChoices, nStayWins, stayWinPercent, nSwitchWins},
r := RandomInteger[{1, 3}, nGames];
winningDoors = r;
firstChoices = r;
nStayWins = Count[Transpose[{winningDoors, firstChoices}], {d_, d_}];
stayWinPercent = N[100 nStayWins/nGames];
nSwitchWins = nGames - nStayWins;
Grid[{{"Strategy", "Wins", "Win %"}, {"Stay", Row[{nStayWins, "/", nGames}], stayWinPercent},
{"Switch", Row[{nSwitchWins, "/", nGames}], 100 - stayWinPercent}}, Frame -> All]]
</lang>
 
 
 
=={{header|MATLAB}}==