Monty Hall problem: Difference between revisions

Added Easylang
imported>Myrmidon
(add standard ml implementation)
(Added Easylang)
Line 1,283:
<pre>Staying wins 286889 times.
Switching wins 713112 times.</pre>
 
=={{header|EasyLang}}==
{{trans|FreeBASIC}}
<syntaxhighlight lang=easylang>
max = 1000000
for i = 1 to max
car_door = random 3
chosen_door = random 3
if car_door <> chosen_door
montys_door = 6 - car_door - chosen_door
else
repeat
montys_door = random 3
until montys_door <> car_door
.
.
if car_door = chosen_door
stay += 1
.
if car_door = 6 - montys_door - chosen_door
switch += 1
.
.
print "If you stick to your choice, you have a " & stay / max * 100 & " percent chance to win"
print "If you switched, you have a " & switch / max * 100 & " percent chance to win"
</syntaxhighlight>
{{out}}
<pre>
If you stick to your choice, you have a 33.36 percent chance to win
If you switched, you have a 66.64 percent chance to win
</pre>
 
=={{header|Eiffel}}==
2,063

edits