Monty Hall problem: Difference between revisions

(→‎{{header|Java}}: fixed logic)
Line 12:
import flash.display.Sprite;
 
public class MonteyHallMontyHall extends Sprite
{
public function MonteyHallMontyHall()
{
var iterations:int = 30000;
var doors:Array = [0, 0, 0];
var switchWins:int = 0;
var stayWins:int = 0;
Line 23 ⟶ 22:
for (var i:int = 0; i < iterations; i++)
{
var doors[Math.round(Math.random():Array *= 2)][0, =0, 10];
var choice:int = doors[Math.roundfloor(Math.random() * 23)] = 1;
var choice:int = Math.floor(Math.random() * 3);
var shown:int;
do
{
shown = Math.roundfloor(Math.random() * 23);
} while (doors[shown] !== 1 &&|| shown !== choice);
stayWins += doors[choice];
switchWins += (doors[choice]3 ==- 0)?choice 1:- 0shown];
doors = [0, 0, 0];
}
Anonymous user