• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Maths challenge No. 3

Page 7 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.


<< Dexion, if you open two doors the chance of me finding the bathroom is 100% >>



Yep, your right. However, what I wanted to say was finding the toilet behind the &quot;opened&quot; doors. Not behind a closed one. In that case, it would be 2/3 chance. Should I have made it more &quot;restricted&quot;? as to having a 2 keys for 3 locked doors? LOL You get my point.

I still don't understand why theres such a huge difference in the concept of switching? The word switching is rather decieving, infact your only taking another chance.

Just read Gustavus's explaination, if that doesn't make sense to you, drop the entire thing. Its getting frustrating for some of us trying to explain it. Like how Callspread said, just don't go betting on anything.
 
sheesh, 150 posts about this same problem? well, anyways, here's a python implementation of the problem for anyone who still has doubt that switching is the way to go:
(if you can't program or don't know python, don't worry.. python is very readable code)

(grr, formatting code in these forums is HARD.. where is our 'pre' tag?)

from random import randint

# this function runs through the process one time, and returns TRUE
# if the contestant wins the car. if argument &quot;switch&quot; is TRUE it
# will switch the answer, and if FALSE it will stick with the first
# choice
def wincar(switch):
        cardoor = randint(1,3)
        firstpick = randint(1,3)

        # get the door that the host reveals (goat)
        freebie = 1
        while (freebie != cardoor and freebie != firstpick):
                freebie = freebie + 1

        if (switch):
                newpick = 1
                while (newpick != freebie and newpick != firstpick):
                        newpick = newpick + 1
                return (newpick == cardoor)

        else:
                return (firstpick == cardoor)

def getwins(attempts, switch):
        wins = 0
        for x in xrange(0, attempts):
                if wincar(switch): wins = wins + 1
        print &quot;Won the car &quot; + str(wins) + &quot; times out of &quot; + str(attempts) + &quot; attempts\n&quot;


def main():

        print &quot;Results when you stick with initial choice:&quot;
        getwins(1000,0)

        print &quot;Results when you always switch:&quot;
        getwins(1000,1)

main()


Here's the output when running the program:

C:\TEMP>python doors.py
Results when you stick with initial choice:
Won the car 312 times out of 1000 attempts

Results when you always switch:
Won the car 696 times out of 1000 attempts

Running it over and over again produces about the same result (1/3 and 2/3)
 
Gustavus:

I don't speak a word of Japanese (well, other than konichiwa 😛) but it means Good Afternoon. Or is it hello? Ah, I can never remember. 😕
 
Thanks to everybody who clearly explained it was 1/3 and 2/3.

I stole your code hatboy to look at later. I don't know java but I know a little c++ so I wanted to compare. If that upsets you then I'll delete it but I didn't think you'd care.

 
Back
Top