Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
28
Task/100-prisoners/APL/100-prisoners.apl
Normal file
28
Task/100-prisoners/APL/100-prisoners.apl
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
∇ R ← random Nnc; N; n; c
|
||||
(N n c) ← Nnc
|
||||
R ← ∧/{∨/⍵=c[n?N]}¨⍳N
|
||||
∇
|
||||
|
||||
∇ R ← follow Nnc; N; n; c; b
|
||||
(N n c) ← Nnc
|
||||
b ← n N⍴⍳N
|
||||
R ← ∧/∨⌿b={⍺⊢c[⍵]}⍀n N⍴c
|
||||
∇
|
||||
|
||||
∇ R ← M timesSimPrisoners Nn; N; n; m; c; r; s
|
||||
(N n) ← Nn
|
||||
R ← 0 0
|
||||
m ← M
|
||||
LOOP: c←N?N
|
||||
r ← random N n c
|
||||
s ← follow N n c
|
||||
R ← R + r,s
|
||||
→((m←m-1)>0)/LOOP
|
||||
R ← R ÷ M
|
||||
∇
|
||||
|
||||
⎕TS
|
||||
'>>>>>'
|
||||
1000 timesSimPrisoners 100 50
|
||||
'>>>>>'
|
||||
⎕TS
|
||||
Loading…
Add table
Add a link
Reference in a new issue