The Monty Hall Problem

One of my friends here in Australia left ‘The Curious Incident of the Dog in the Night-Time’ at our house. So I started to read it and have finished reading it and it is excellent!

Anyway there’s a point in the book where they talk about The Monty Hall Problem (see the link for information), my flat mate Andy does not believe changing matters. So I have written a little program in C# .NET that tries to prove The Monty Hall Problem. Here it is, although the results really seem to prove absolutely nothing –

Random r=new Random();

bool change=true;

int correctChange=0;
int correctNoChange=0;
int maxLoop=100000000;

for(int x=0;x<maxLoop;x++)
{
    int correctAnswer=r.Next(3);
    int guess=r.Next(3);
    int showDoor=0;

    showDoor=correctAnswer%2 + 1;
    correctNoChange+=(guess==correctAnswer)?1:0;
    guess=((showDoor+correctAnswer)%2)+1;
    correctChange+=(guess==correctAnswer)?1:0;
}

I ran this 10,000,000,000 times and the difference on changing was 161026.