RosettaCodeData/Task/Monty-Hall-problem/Langur/monty-hall-problem.langur
2026-04-30 12:34:36 -04:00

22 lines
429 B
Text

var switchWins = 0
var stayWins = 0
for of 1000000 {
var doors = [0 ,0, 0]
val winner = random(3)
doors[winner] = 1
val choice = random(3)
var shown = random(3)
while doors[shown] or shown == choice {
shown = random(3)
}
stayWins += doors[choice]
switchWins += doors[2 - choice - shown]
}
writeln "Staying wins {{stayWins}} times."
writeln "Switching wins {{switchWins}} times."