Monty Hall problem: Difference between revisions

m (→‎{{header|Perl}}: Removed redundant "exit(0)".)
(→‎{{header|PHP}}: fixed logic)
Line 842:
$stay_win = 0;
forforeach ($i=0;range(1, $i<$iterations;) as $i++){
$doors = array(0, 0, 0);
$doors[randarray_rand(0,2$doors)] = 1;
$choice = randarray_rand(0,2$doors);
$shown;do {
while( $shown != $choice && array_rand($doors[$shown] != 1);
} while($shown == rand(0,2$choice || $doors[$shown] == 1);
$stay_win += $doors[$choice];
$switch_win += ($doors[3 - $choice] ==- 0) ? 1 : 0$shown];
}
Anonymous user