Monty Hall problem using Go

“Suppose you’re on a game show, and you’re given the choice of three doors: Behind one door is a car; behind the others, goats. You pick a door, say No. 1, and the host, who knows what’s behind the doors, opens another door, say No. 3, which has a goat. He then says to you, “Do you want to pick door No. 2?” Is it to your advantage to switch your choice?”

source: https://en.wikipedia.org/wiki/Monty_Hall_problem

This code is a simulation to show what happens if to switch in Monty Hall problem using Go.


How to test by yourself

$ git clone https://github.com/PabloEmidio/Monty-Hall-problem-using-Go
$ cd Monty-Hall-problem-using-Go
$ go run .

Some examples

[example@example ~]$ go run .
500 matches done, switching the door it'd win 341 times, 68.2 of the matches.

[example@example ~]$ go run .
500 matches done, switching the door it'd win 332 times, 66.4 of the matches.

GitHub

View Github