Monty Hall Problem - Python 3

Here is the homework problem: For the “Monty Hall” problem discussed in class, modify the code montyhallproblem.py (shown below) to have Monty open a door at random (after a door is selected by the contestant). This means that in some cases Monty will open a door with the car, which means the contestant cannot win in this situation. Demonstrate (with your code) that switching your door yields a 50% chance of winning the car. You will have to edit the code in the part of the codewhere the door is opened(remember to prevent the code from opening the door that is already selected!).

Here is the code mentioned above:

NOTE: You might need to look up the Monty Hall problem before answering this.

In all honesty, I understand the way I do it better than the way my professor does it, so here's what I have:

At the moment, what I'm trying to do is figure out how to make sure that the door Monty opens ("doorC") isn't the same door that I opened ("doorA"). I can't figure out how to do this. I'm doing this on Jupyter Notebook, which uses Python 3. It's a part of the Anaconda program.

Note by Callie Ferguson
1 week, 2 days ago

No vote yet
1 vote

  Easy Math Editor

This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.

When posting on Brilliant:

  • Use the emojis to react to an explanation, whether you're congratulating a job well done , or just really confused .
  • Ask specific questions about the challenge or the steps in somebody's explanation. Well-posed questions can add a lot to the discussion, but posting "I don't understand!" doesn't help anyone.
  • Try to contribute something new to the discussion, whether it is an extension, generalization or other idea related to the challenge.
  • Stay on topic — we're all here to learn more about math and science, not to hear about your favorite get-rich-quick scheme or current world events.

MarkdownAppears as
*italics* or _italics_ italics
**bold** or __bold__ bold

- bulleted
- list

  • bulleted
  • list

1. numbered
2. list

  1. numbered
  2. list
Note: you must add a full line of space before and after lists for them to show up correctly
paragraph 1

paragraph 2

paragraph 1

paragraph 2

[example link](https://brilliant.org)example link
> This is a quote
This is a quote
    # I indented these lines
    # 4 spaces, and now they show
    # up as a code block.

    print "hello world"
# I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
MathAppears as
Remember to wrap math in \( ... \) or \[ ... \] to ensure proper formatting.
2 \times 3 2×3 2 \times 3
2^{34} 234 2^{34}
a_{i-1} ai1 a_{i-1}
\frac{2}{3} 23 \frac{2}{3}
\sqrt{2} 2 \sqrt{2}
\sum_{i=1}^3 i=13 \sum_{i=1}^3
\sin \theta sinθ \sin \theta
\boxed{123} 123 \boxed{123}

Comments

Sort by:

Top Newest

Hi Callie. The first I thing I noticed is that the "permutations" function you are using doesn't seem to be yielding the array you need. In your professor's code, he generates an array with elements [1, 0, 0], [0, 1, 0], and [0, 0, 1]. This represents all the different starting arrangements for the doors. However, the array which your function is producing appears to be yielding [1, 0, 0], [1, 0, 0], and [0, 1, 0], so the first 2 are the same and the last one is missing.

Perhaps this is the issue?

David Stiff - 6 days, 12 hours ago

Log in to reply

×

Problem Loading...

Note Loading...

Set Loading...