This repository contains implementations of the Monty Hall Problem simulation in multiple programming languages.
The C++ implementation (montyhall.cpp) provides a simulation of the Monty Hall Problem.
The montyhall.cpp file contains the source code for the Monty Hall Problem simulation.
To compile the code, use the following command:
g++ montyhall.cpp -o MontyHallTo execute the compiled program, run the following command:
./MontyHall [iterations]Replace [iterations] with the desired number of iterations for the simulation. If not provided, it defaults to 10,000 iterations.
The Python implementation (montyhall.py) provides a simulation of the Monty Hall Problem.
To run the Python code, ensure you have Python installed. The code requires NumPy library to be installed as well.
pip install numpyTo execute the Python script, use the following command:
python MontyHall.py [iterations]Replace [iterations] with the desired number of iterations for the simulation. If not provided, it defaults to 100,000 iterations.
The MontyHall.sh shell script automates the execution of the C++ program for multiple runs and calculates the average execution time.
To use the shell script, run the following command:
bash MontyHall.shThe script will compile the montyhall.cpp file, execute the program with a specified number of iterations and choices, and calculate the average execution time over multiple runs. You can modify the script to adjust the number of runs and other parameters.