Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
38
Task/Monty-Hall-problem/PL-I/monty-hall-problem.pli
Normal file
38
Task/Monty-Hall-problem/PL-I/monty-hall-problem.pli
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
*process source attributes xref;
|
||||
ziegen: Proc Options(main);
|
||||
/* REXX ***************************************************************
|
||||
* 30.08.2013 Walter Pachl derived from Java
|
||||
**********************************************************************/
|
||||
Dcl (switchWins,stayWins) Bin Fixed(31) Init(0);
|
||||
Dcl doors(3) Bin Fixed(31);
|
||||
Dcl (plays,r,choice) Bin Fixed(31) Init(0);
|
||||
Dcl c17 Char(17) Init((datetime()));
|
||||
Dcl p9 Pic'(9)9' def(c17) pos(5);
|
||||
i=random(p9);
|
||||
Do plays=1 To 1000000;
|
||||
doors=0;
|
||||
r=r3();
|
||||
doors(r)=1;
|
||||
choice=r3();
|
||||
Do Until(shown^=choice & doors(shown)=0);
|
||||
shown=r3();
|
||||
End;
|
||||
If doors(choice)=1 Then
|
||||
stayWins+=1;
|
||||
Else
|
||||
switchWins+=1;
|
||||
End;
|
||||
Put Edit("Switching wins ",switchWins," times.")(Skip,a,f(6),a);
|
||||
Put Edit("Staying wins ",stayWins ," times.")(Skip,a,f(6),a);
|
||||
|
||||
r3: Procedure Returns(Bin Fixed(31));
|
||||
/*********************************************************************
|
||||
* Return a random integer: 1, 2, or 3
|
||||
*********************************************************************/
|
||||
Dcl r Bin Float(53);
|
||||
Dcl res Bin Fixed(31);
|
||||
r=random();
|
||||
res=(r*3)+1;
|
||||
Return(res);
|
||||
End;
|
||||
End;
|
||||
Loading…
Add table
Add a link
Reference in a new issue