##### The Monty Hall Problem! 🐐 🚘

# Hiya everyone!

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!

### Explanation

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!

### Also:

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)

### Sources:

https://betterexplained.com/articles/understanding-the-monty-hall-problem/

https://en.wikipedia.org/wiki/Monty_Hall_problem

Myself brain as well! xD

Here are some other sites if you want to know more:

https://statisticsbyjim.com/fun/monty-hall-problem/

https://www.statisticshowto.com/probability-and-statistics/monty-hall-problem/

https://www.scientificamerican.com/article/the-3-door-monty-hall-problem/

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.

Proof:

Entia non sunt multiplicanda praeter necessitatem

Which means:

No more things should be presumed to exist than are absolutely necessary.

This is a law called Occam's razor

yea, thats a great quote! ;) @DigitCommander

@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.

ah nice thanks for that! :D @DigitCommander

@Bookie0 You're welcome

@Bookie0

Seconds?? I thought you were only supposed to eat a **minute** amount...

Lol

please please use .upper()

ok i will lol thanks! ;) @BobTheTomatoPie

lmao thanks! @DynamicSquid

im losing brain cells trying to understand

but i still upvoted

I made my own repl (Python) to prove the Monty hall problem!

https://repl.it/@LoveTheBears1O1/The-Monty-Hall-ParadoxProblem#main.py

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.

oh wow what a coincidence i am also making the proof for that :) @LoveTheBears1O1

ah this makes the fatal flaw in assuming i dont want a goat

Lol car is better @Nettakrim

@Bookie0 I think this is a good picture to represent the problem:

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:

https://repl.it/@zypherion/MontyHallConundrum#main.py

yea, i first wanted to do the user interaction because it seemed a tad easier, but im now trying to work on the proof. yours is very good, but mine is going to be probably different and very bad coding lol.

but thanks anyways ;) @zypherion

very interesting

thanks! @BootsyStraps

brain goes kaboom

hum yea try again a few times and youre more than likely to get the car! ;) @ironblockhd

woah nice job! ;) @NDLFOREVER

hehe I switched lol,

wheres my car?? >:( I don't eve have a license or have an idea how to drive BUT WHERES MY LAMBO???

Shouldn't this be in the share section?

no because this is a tutorial. The repl is just a continuation of the tutorial @HahaYes

@Bookie0 how does this get 16 upvotes when my essay gets 5 smh

lmdao it should @HahaYes

@BobTheTomatoPie ah vinicator is back

yes he is @HahaYes

dude do you really care about it? also you already asked this @HahaYes

how does this get 14 upvotes when my essay I wrote about computer science gets 5. Smh repl users

do you care about upvotes **that** much? @HahaYes

omg im proud of you bookie it no longer says upvoting is caring @Bookie0

yea im tired of saying it i dont put anything now i guess its better @BobTheTomatoPie

This is a really interesting brain teaser. I think it was on Brain Games or TedEd riddles... I don't remember which one but I really liked your simulator!

thank you! ;) @theroadtocode

lol thanks! ;) @DannyIsCoding

Nice!

But tell me...

# Why you are a good programmer?

thanks! ;)

also wdym with your question? @ZDev1

@Bookie0 it is not a question

I just said 'Why are you a good programmer?' just to say that you are too good ;)

oh ok lol thanks @ZDev1

@Bookie0 hehe np

Nice!

thanks! ;) @VulcanWM

np :) @Bookie0

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.

@SixBeeps "son"? what what

oh yea, i could do that thanks!

~~son? lmao~~

@SixBeeps

lol idk @DynamicSquid

hum i tried doing upper(), is it like this?

because when i did it, and typed `a`

(without capitals), it doesnt work... :/

@SixBeeps

You can also just put upper after the input like input().upper() @Bookie0

@Bookie0 you mean "thanks dad!" lol

thats nice

thanks! ;) @HahaYes

thanks! ;) @NoNameByProgram

Nice tutorial (Yes, your code could be made shorter, but it's good anyway)!

What I thought was really the joke:

@aguy11 thanks!

and yes that is a shameful joke lmao lol