September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
17
Task/Monty-Hall-problem/Zkl/monty-hall-problem.zkl
Normal file
17
Task/Monty-Hall-problem/Zkl/monty-hall-problem.zkl
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
const games=0d100_000;
|
||||
|
||||
reg switcherWins=0, keeperWins=0, shown=0;
|
||||
do(games){
|
||||
doors := L(0,0,0);
|
||||
doors[(0).random(3)] = 1; // Set which one has the car
|
||||
choice := (0).random(3); // Choose a door
|
||||
while(1){ shown = (0).random(3);
|
||||
if (not (shown == choice or doors[shown] == 1)) break; }
|
||||
switcherWins += doors[3 - choice - shown];
|
||||
keeperWins += doors[choice];
|
||||
}
|
||||
|
||||
"Switcher Wins: %,d (%3.2f%%)".fmt(
|
||||
switcherWins, switcherWins.toFloat() / games * 100).println();
|
||||
"Keeper Wins: %,d (%3.2f%%)".fmt(
|
||||
keeperWins, keeperWins.toFloat() / games * 100).println();
|
||||
Loading…
Add table
Add a link
Reference in a new issue