Monty Hall door game that is run 1000 times
The program creates 3 doors with goats and puts a car behind a randomly chosen door. Then it randomly picks one of them and then reveals the one that is not chosen and has the goat inside. Then it checks both choices: stay and switch and starts counting which one resulted a car. The loop is done 1000 times and here are some of the outputs:
Changing gave us 676 cars.
Being stubborn gave us 324 cars.
Changing gave us 679 cars.
Being stubborn gave us 321 cars.
Changing gave us 652 cars.
Being stubborn gave us 348 cars.
Then I decided to run the game billion times:
Changing gave us 666673616 cars.
Being stubborn gave us 333326384 cars.
We can see that switching the door always gives us roghly 2 times more cars than staying, which proves the theory. Interesting fact, the last test took about 30-40 seconds for my computer to play the game billion times.