Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
23
Task/Monty-Hall-problem/Seed7/monty-hall-problem.seed7
Normal file
23
Task/Monty-Hall-problem/Seed7/monty-hall-problem.seed7
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
$ include "seed7_05.s7i";
|
||||
|
||||
const proc: main is func
|
||||
local
|
||||
var integer: switchWins is 0;
|
||||
var integer: stayWins is 0;
|
||||
var integer: winner is 0;
|
||||
var integer: choice is 0;
|
||||
var integer: shown is 0;
|
||||
var integer: plays is 0;
|
||||
begin
|
||||
for plays range 1 to 10000 do
|
||||
winner := rand(1, 3);
|
||||
choice := rand(1, 3);
|
||||
repeat
|
||||
shown := rand(1, 3)
|
||||
until shown <> winner and shown <> choice;
|
||||
stayWins +:= ord(choice = winner);
|
||||
switchWins +:= ord(6 - choice - shown = winner);
|
||||
end for;
|
||||
writeln("Switching wins " <& switchWins <& " times");
|
||||
writeln("Staying wins " <& stayWins <& " times");
|
||||
end func;
|
||||
Loading…
Add table
Add a link
Reference in a new issue