Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
20
Task/Monty-Hall-problem/Dyalect/monty-hall-problem.dyalect
Normal file
20
Task/Monty-Hall-problem/Dyalect/monty-hall-problem.dyalect
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
var switchWins = 0
|
||||
var stayWins = 0
|
||||
|
||||
for plays in 0..1000000 {
|
||||
var doors = [0 ,0, 0]
|
||||
var winner = rnd(max: 3)
|
||||
doors[winner] = 1
|
||||
var choice = rnd(max: 3)
|
||||
var shown = rnd(max: 3)
|
||||
|
||||
while doors[shown] == 1 || shown == choice {
|
||||
shown = rnd(max: 3)
|
||||
}
|
||||
|
||||
stayWins += doors[choice]
|
||||
switchWins += doors[3 - choice - shown]
|
||||
}
|
||||
|
||||
print("Staying wins \(stayWins) times.")
|
||||
print("Switching wins \(switchWins) times.")
|
||||
Loading…
Add table
Add a link
Reference in a new issue