Jump to content

Monty Hall problem: Difference between revisions

m
→‎{{header|Perl 6}}: use fix-size array and atomic increment in .race block
m (→‎version 1: added the source of the Michael Mol quote about showing timings for program execution times.)
m (→‎{{header|Perl 6}}: use fix-size array and atomic increment in .race block)
Line 2,682:
for 3, 10 -> $doors {
my %atomicint @wins[2];
say "With $doors doors: ";
for Stay, 'Staying', Switch, 'Switching' -> $s, $name {
(^TRIALS).race.map: {
++%@wins{[$s}]⚛++ if play($s, doors => $doors) == Car;
}
say " $name wins ",
round(100*%@wins{[$s}] / TRIALS),
'% of the time.'
}
2,392

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.