Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9198215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:14:06+00:00 2026-06-17T22:14:06+00:00

According to the probabilities I’ve read about, switching doors should yield ~66% chance to

  • 0

According to the probabilities I’ve read about, switching doors should yield ~66% chance to pick the correct door. This code below is what I’ve come up with and it spits out roughly 50% wins instead of the 66% I am expecting. Any help on where I’m going wrong here would be much appreciated.

for (int count = 0; count < 10000; count++)
{
    // Chooses which door contains DAT GRAND PRIZE YO.
    wDoor = rand() % 3 + 1;

    // AI Contestants Door choice
    aiDoor = rand() % 3 + 1;

    // Using oldChoice to ensure same door isn't picked.
    oldChoice = aiDoor;
    // Used in determining what door to open.
    openedDoor = aiDoor;

    // "Open" a door that is not the winning door and not the door chosen by player.
    do
    {
                openedDoor = rand() % 3 + 1;

    }while (openedDoor != wDoor && openedDoor != aiDoor);

    // Select new door between the remaining two.
    do
    {
              aiDoor = rand() % 3 + 1;

    }while (aiDoor != oldChoice && aiDoor != openedDoor);

    // Increment win counter if new door is correct.
    if (aiDoor == wDoor)
    {
               chooseAgain++;
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:14:07+00:00Added an answer on June 17, 2026 at 10:14 pm

    Your while conditions are the wrong way round:

    while (openedDoor != wDoor && openedDoor != aiDoor)
    

    should be

    while (openedDoor == wDoor || openedDoor == aiDoor)
    

    etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According to this after installing resharper code completion should looks like this but what
According to this article from Herb Sutter, one should always pick Class Specializing over
According to docs at http://code.google.com/p/minify/wiki/UriRewriting $min_serveOptions['rewriteCssUris'] = false; I should be able to add
According to an answer in this thread , semicolons are bad and should be
According to this question , I should try to use Preallocation is Matlab. Now
According to this question and the documentation of attr_readonly the following should be possible:
According to this SO post: How to check the TEMPLATE_DEBUG flag in a django
According MSDN, FxCop is an application that analyzes managed code assemblies (code that targets
According to this post , IDEA uses Osmorc to run OSGi frameworks. It, in
According this article , generic JPA DAO(Data Access Object) is a pretty nice pattern.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.