RosettaCodeData/Task/100-prisoners/APL/100-prisoners.apl
2023-07-01 13:44:08 -04:00

28 lines
472 B
APL
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 NN
R /b={c[]}n Nc
R M timesSimPrisoners Nn; N; n; m; c; r; s
(N n) Nn
R 0 0
m M
LOOP: cN?N
r random N n c
s follow N n c
R R + r,s
((mm-1)>0)/LOOP
R R ÷ M
⎕TS
'>>>>>'
1000 timesSimPrisoners 100 50
'>>>>>'
⎕TS