Monty Hall problem: Difference between revisions

m
(Added Quackery.)
Line 1,278:
<lang dyalect>var switchWins = 0
var stayWins = 0
 
for plays in 0..1000000 {
var doors = [0 ,0, 0]
var winner = rnd(max: 3)
doors[winner] = 1
var choice = rnd(max: 3)
var shown = rnd(max: 3)
 
while doors[shown] == 1 || shown == choice {
shown = rnd(max: 3)
}
 
stayWins += doors[choice]
switchWins += doors[3 - choice - shown]
}
 
print("Staying wins \(stayWins) times.")
print("Switching wins \(switchWins) times.")</lang>
Line 1,299:
{{out}}
 
<pre>Staying wins 431683286889 times.
Switching wins 568318713112 times.</pre>
 
=={{header|Eiffel}}==
Anonymous user