Lets start with a dad joke because why not!
Hahahaha— ok whatever…
Yea so recently I was reading a book called The Curious Incident of the Dog in the Night-Time, by Mark Haddon. (Btw its a really great book). In it, they talked about the Monty Hall Problem.
What is it?
Now what is the Monty Hall Problem?
So the Monty Hall Problem is kinda like a brain teaser; its a probability puzzle which was based a bit on a game show Let’s Make a Deal and it was named after the host, Monty Hall.
So imagine in front of you there are 3 doors, and you don’t know what’s behind those doors. 2 doors contains goats and 1 of them contains a car.
The presenter asks you which door you first want to pick. Let’s say you pick Door A. Next, the host, who knows what's behind the doors, opens another door, say Door C, which has a goat. He then says to you, "Do you want to pick door Door B?” Is it to your advantage to switch your choice?
Surprisingly, the odds aren’t 50-50, as you might think, because you have two doors. If you switch doors you’ll win 2/3 of the time!
Aight so its a tad hard to explain, but I will try to explain as EZ and simple as possible ;)
So if you pick a door and stay there, you have a 1/3 chance of winning, because you have a 1 in 3 chance of obtaining the car on the first choice, right?
So that means that the other doors must have the rest of the chances, or 2/3.
Here is a picture to kind of represent it:
What I try to think about it:
So personally, what I think of is this (disclaimer: my explanation might not be that good/valid)
So lets remember that there are more goats than cars, so you have more chances of first picking a goat in the 1st choice.
Lets say you pick Door A, and it has a goat behind it (but you don’t know). Since the presenter will then open a door with a goat next (like door B), then that means that the remaining door must be a car:
Door A: goat (1st choice, user doesn’t know)
Door B: goat (open door, user does know)
Door C: car (user doesn’t know)
In that case, if the user switches, they will win.
So for that specific case that I just mentioned, you have a 2/3 chance of having that case.
Thats why switching is better, because you should assume you have that case where switching will make you win!
Now you might think that its simpler now, but remember that the user doesn’t know what’s behind those doors!
You might think since you have more chances of getting goat in the beginning —and thus having more chances of winning with switching— then that means every time you pick a door it will be a goat. Indeed, you’re most likely to pick a door with a goat behind it, but that doesn’t mean that the possibility of having a door with a car is completely impossible.
See that’s the thing with probabilities. You can never know exactly if the coin you flip will land on heads or tails. Probabilities can help you try to “guess” the future, but you shall never be sure.
Here is a something that a user said, I think it really explains well this problem:
To me, the clearest explanation is that the only way to get it wrong by switching is to have picked the correct door in the first place. The odds of picking the correct door first are 1 in 3. (From a Reddit post)
Myself brain as well! xD
Here are some other sites if you want to know more:
Ok so the repl attached is a simulator based on the point of view of the person playing this challenge. (When prompted, please write exactly or it won’t work properly ;)
pleaseeee don’t look at the code because you will most likely have a stroke or something. What I did could most likely be shortened and made easier….
I hope you enjoyed reading this tutorial, and learnt something new!
As usual, feel free to comment, say your points of views, give feedback, etc. :)
Also I might try to make everything random, meaning that I make the computer do the choices on its own for like 100 times, to show that if you switch you have more chances of winning, so keep an eye out for that! ;)
Anyways, thanks again and Have A Really Fantastic Day!!! :D
I've read The Curious Incident of the Dog in the Night-Time.
Entia non sunt multiplicanda praeter necessitatem
No more things should be presumed to exist than are absolutely necessary.
This is a law called Occam's razor
@Bookie0 Thanks. If you want another bit of proof, Christopher Boone, the main protagonist, does a mental problem called Conway's Soldiers which is when you have an infinite chess board and you can move tiles. BUT you can only move a tile when it can move horizontally or vertically over a coloured tile and when you do this, you have to put a tile where the previous tile was. I don't think you can do it in a repl since it's infinite although there might be a way.
I got the car first try btw.
I made my own repl (Python) to prove the Monty hall problem!
Enter the number of times you want it tested (I recommend 100), and it will calculate the number of times the player would switch and win and stay and win.
Nice, this was one of the very first things I did to help learn python (spoiler, that was only around the beginning of the year).
But my focus was more on "How quickly can we iterate through rounds to prove out the probabilities" and less "Have a user interact in every round and provide feedback"...
So it's interesting to see the two different approaches. Here's mine:
how does this get 14 upvotes when my essay I wrote about computer science gets 5. Smh repl users
I'm proud of you, son.
Though you could've just called upper() on the user input instead of asking them to make it uppercase.