Monty Hall problem: Difference between revisions
Content deleted Content added
→{{header|Perl 6}}: modernize |
m →{{header|Sidef}}: modified the code to work with the latest version of Sidef |
||
Line 3,330: | Line 3,330: | ||
var show; |
var show; |
||
do { |
|||
{ show = 3.rand.int } |
|||
show = 3.rand.int |
|||
} while (show ~~ [chosen, prize]); |
|||
given(chosen) |
given(chosen) { |
||
when (prize) { stayWins += 1 } |
when (prize) { stayWins += 1 } |
||
when (3 - show - prize) |
when ([3 - show - prize]) { switchWins += 1 } |
||
default { die "~ error ~" } |
default { die "~ error ~" } |
||
} |
|||
} |
} |
||
Line 3,343: | Line 3,345: | ||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Staying wins |
Staying wins 31.20% of the time. |
||
Switching wins |
Switching wins 68.80% of the time. |
||
</pre> |
</pre> |
||