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