View Single Post
Old 16-08-2009, 20:39   #53
Fobic
Inactive
 
Join Date: Dec 2005
Posts: 23
Fobic is a jewel in the roughFobic is a jewel in the roughFobic is a jewel in the roughFobic is a jewel in the roughFobic is a jewel in the rough
Re: Programming Challenges?

Quote:
Originally Posted by Damien View Post
Monty Hall Problem:
Interesting code: made me think .... always a good thing.
Liked your shortcut for resetting the list.

However, i dont think the code works the way it should for the case when the contestant changes their choice.

Quote:
Originally Posted by Damien View Post
Code:
                {
                   doors.Remove(GOAT);
                    if (doors[random.Next(2)] == CAR) //Did they get the car
                        DidChangeSuccessRate++;
                    doors.Add(GOAT);
                }
You seem to be removing the first door you come across with a Goat behind it (which may even be the contestant's chosen door) and then choosing at random from the 2 remaining doors, rather than swapping to the unchosen door.

I suspect this will give results of 33% and 50% in your output which is not the correct answer.
Fobic is offline   Reply With Quote