Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
35
Task/Monty-Hall-problem/NetRexx/monty-hall-problem.netrexx
Normal file
35
Task/Monty-Hall-problem/NetRexx/monty-hall-problem.netrexx
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/* NetRexx ************************************************************
|
||||
* 30.08.2013 Walter Pachl translated from Java/REXX/PL/I
|
||||
**********************************************************************/
|
||||
options replace format comments java crossref savelog symbols nobinary
|
||||
|
||||
doors = create_doors
|
||||
switchWins = 0
|
||||
stayWins = 0
|
||||
shown=0
|
||||
Loop plays=1 To 1000000
|
||||
doors=0
|
||||
r=r3()
|
||||
doors[r]=1
|
||||
choice = r3()
|
||||
loop Until shown<>choice & doors[shown]=0
|
||||
shown = r3()
|
||||
End
|
||||
If doors[choice]=1 Then
|
||||
stayWins=stayWins+1
|
||||
Else
|
||||
switchWins=switchWins+1
|
||||
End
|
||||
Say "Switching wins " switchWins " times."
|
||||
Say "Staying wins " stayWins " times."
|
||||
|
||||
method create_doors static returns Rexx
|
||||
doors = ''
|
||||
doors[0] = 0
|
||||
doors[1] = 0
|
||||
doors[2] = 0
|
||||
return doors
|
||||
|
||||
method r3 static
|
||||
rand=random()
|
||||
return rand.nextInt(3) + 1
|
||||
Loading…
Add table
Add a link
Reference in a new issue