Simulate the Monty Hall Problem I've never been able to wrap my head around the Monty Hall problem. Here's the premise:


  Suppose you're on a game show, and you're given the choice of three doors: Behind one door is a car; behind the others, goats. You pick a door, say No. 1, and the host, who knows what's behind the doors, opens another door, say No. 3, which has a goat. He then says to you, "Do you want to pick door No. 2?" Is it to your advantage to switch your choice?


Run 10,000 simulations. Output the win percentage of switching. For example: 

&gt; 66.66733%
JavaScript 52

for(i=s=0;i++&lt;1e4;)s+=Math.random()&lt;2/3;alert(s/100)


Doors are 1:[0,1/3), 2:[1/3,2/3), 3:[2/3, 1)

Assume the prize is always in door 3. If the guest picks doors 1 or 2, which is range [0,2/3), and they switch, they've won the prize.