RosettaCodeData/Task/Monty-Hall-problem/Icon/monty-hall-problem.icon
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07:00

19 lines
477 B
Text

procedure main(arglist)
rounds := integer(arglist[1]) | 10000
doors := '123'
strategy1 := strategy2 := 0
every 1 to rounds do {
goats := doors -- ( car := ?doors )
guess1 := ?doors
show := goats -- guess1
if guess1 == car then strategy1 +:= 1
else strategy2 +:= 1
}
write("Monty Hall simulation for ", rounds, " rounds.")
write("Strategy 1 'Staying' won ", real(strategy1) / rounds )
write("Strategy 2 'Switching' won ", real(strategy2) / rounds )
end