https://github.com/pbodnar/monty-hall-goat-problem
Simulates and explains the Monty Hall problem (in Java).
https://github.com/pbodnar/monty-hall-goat-problem
java monty-hall-problem monty-hall-simulator
Last synced: 4 months ago
JSON representation
Simulates and explains the Monty Hall problem (in Java).
- Host: GitHub
- URL: https://github.com/pbodnar/monty-hall-goat-problem
- Owner: pbodnar
- License: apache-2.0
- Created: 2020-05-10T11:05:00.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-05-10T11:58:56.000Z (about 5 years ago)
- Last Synced: 2025-01-16T02:16:46.497Z (5 months ago)
- Topics: java, monty-hall-problem, monty-hall-simulator
- Language: Java
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# About
This repo contains a simple Java app (see [Main.java](Main.java)) which simulates the [Monty Hall problem](https://en.wikipedia.org/wiki/Monty_Hall_problem). It simply outputs results of repeated simulated plays of the game.
So yes, it is yet another repo dedicated to this interesting problem / puzzle. :)
But, unlike code in some of the other repos, this repo code is as concise and readable as possible. The code also includes comments that try to explain why one of the two playing strategies is definitely better, so that even non-programmers or non-mathematicians can easily understand what the heck is going on with the goats. ;)
# Running the app
If just reading through the code is not enough, you can compile and run it, of course. You can do that either from your favorite Java IDE, or you can do it from the command line, using the standard Java JDK tools like this:
```
$ javac Main.java$ java Main
play #1: win1: true, win2: false
...
play #99: win1: false, win2: true
play #100: win1: false, win2: true
wins1 (without switch): 28, wins2 (with switch): 72
```