35 lines
827 B
Text
35 lines
827 B
Text
/* 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
|