const int NumDoors = 100;

int randomDoor();

void setup(void)
{
  Serial.begin(115200);
}

void loop(void)
{
  int staySuccess = 0, switchSuccess = 0, trials = 0;
  int doorWithCar, userChoice, counter;
  float staySuccessProbability = 0, switchSuccessProbability = 0;

  counter = trials = 10000;
  while (counter--) {

    doorWithCar = randomDoor();
    userChoice = randomDoor();

    //if user selection matches with door with car, then staying is successful
    if (userChoice == doorWithCar)
      staySuccess++;
    else	//if it does not match then switching is successful
      switchSuccess++;
  }

  staySuccessProbability = ((float)staySuccess) / trials;
  switchSuccessProbability = ((float)switchSuccess) / trials;

  //printf("stay: %f switch: %f\n", staySuccessProbability, switchSuccessProbability);
  Serial.print("stay: ");
  Serial.print(staySuccessProbability, 4);
  Serial.print(" switch: ");
  Serial.println(switchSuccessProbability, 4);
}

int randomDoor()
{
  return rand() % NumDoors;
}