There are 3 doors behind which are two goats and a car. You pick door 1 hoping for the car but don’t open it right away. Monty Hall, the game show host who knows what's behind the doors, opens door 3, which has a goat. Here's the game: do you want to pick door No. 2? Is it to your advantage to switch your choice?

**Key takeaway:** The Monty Hall problem is one of the exciting puzzles to learn the application of probability in algorithmic problem-solving. This helps us to understand that: sometimes our statistical intuition or assumptions are incorrect!

Here most people will assume that both doors are equally like to have the prize, and there is no reason to change. So, most of them stick with their initial choice. But the solution is just the opposite: if we switch doors, we double our probability of winning! But the critical question is — how? Let’s think.

If our initial choice is incorrect, then Monty will always open any remaining doors that do not have the prize. In this situation, the only closed door will have the award, and changing the choice will be lead us to the award. So the conclusion is: if our initial choice is incorrect, then switching the door will ensure 100% chances of success! Think!

- The probability of choosing the incorrect door in the first choice = 2/3, and the “Don’t Switch” strategy always leads to failure. Or in other words, the “Switch” strategy always leads to success.
- Similarly, The probability of choosing the correct door in the first choice = 1/3, and the “Switch” strategy always leads to failure.
- In different words, the probability of choosing the incorrect door is high in the first choice. So our best thought would be: we should "Switch" because our initial choice can be wrong with 2/3 probability! Think!

We will get a clear picture by analyzing and preparing the list of different choices and outcomes: there are only nine different combinations! In the following table, each row shows a different combination of initial door choice, prize door, and the results for the two options — “Don’t Switch” and “Switch.” There could be three doors for the first choice, and for each door, there could be three possibilities: either prize will be present in the same door or any one of the other two doors.

The above table shows all possible situations, and we need to count the number of wins for each door strategy. It is visible that out of 9 choices if we “switch,” then we win 6 times (2/3 probability), and if we “Don’t switch,” then we win 3 times(1/3 probability). I hope this table convinces you that the probability of winning doubles when you switch doors. But again, the critical question is: why did this happen? Let's think!

To understand the solution, we first need to know why your brain gets the incorrect solution which is 50/50. Actually, we are using false assumptions, and that’s why we can’t trust our answers.

Mostly we think of probabilities for independent, random events. Flipping a coin is a good example. The probability of heads is 0.5, and we obtain that simply by dividing the specific outcome by the total number of outcomes. That’s why it feels so right that the final two doors each have a probability of 0.5. However, to produce the correct answer for this method, the process must be random and have probabilities that do not change. Unfortunately, the Monty Hall problem does not satisfy either requirement.

The only random portion of the process is your first choice. When you pick one of the three doors, you truly have a 0.33 probability of picking the correct door. The “Don’t Switch” column in the table verifies this by showing you’ll win 33% of the time if you stick with your initial random choice.

The process stops being random when Monty Hall uses his knowledge about the prize’s location. It’s easiest to understand if you think about it from Monty’s point of view. When it’s time for him to open a door, there are two doors he can open. If he chose the door using a random process, he’d do something like flip a coin. However, Monty is constrained because he doesn’t want to reveal the prize. Monty very carefully opens only a door that does not contain the award. The end result is that the door he doesn’t show you, and lets you switch to, has a higher probability of containing the prize. That’s how the process is neither random nor has constant probabilities.

The probability that your initial door choice is wrong is 0.66. The following sequence is deterministic when you choose the wrong door. Therefore, it happens 66% of the time:

- You pick the incorrect door by random chance. The prize is behind one of the other two doors.
- Monty knows the prize location. He opens the only door available to him that does not have the award.
- By the process of elimination, the award must be behind a door that he does not open.

Because this process occurs 66% of the time and always ends with the prize behind the door that Monty allows you to switch to, the “Switch To” door must have the prize 66% of the time. That matches the table!

Our mental assumptions were based on independent, random events. However, Monty knows the prize location and uses this knowledge to affect the outcomes in a non-random fashion. Once you understand how Monty uses his knowledge to pick a door, the results make sense.

**Enjoy learning, Enjoy thinking!**

Check if a number is prime or not: Primality Test

Given a positive integer n, write a program to check if the number is prime or not. A number n > 1 is said to be a prime number if 1 and n are its only factors. In other words, a prime number is a number that is divisible only by two numbers itself and one.

The Celebrity Problem

There are n+1 people at a party. They might or might not know each other names. There is one celebrity in the group, and the celebrity does not know anyone by their name. However, all the n people know that celebrity by name. You are given the list of people present at the party. And we can ask only one question from each one of them. “Do you know this name”? How many maximum numbers of questions do you need to ask to identify the actual celebrity?

Visual Proof: The Sum of Important Mathematical Series

The summation formulas are used to calculate the sum of the sequence. In this blog, we have discussed the visual proofs: the sum of numbers from 1 to n (arithmetic series), the sum of infinite geometric series, the sum of squares of numbers from 1 to n, etc.