#include pps/lrblib.tc #include pps/library.tc // ref: https://en.wikipedia.org/wiki/100_prisoners_problem yellow [MC '\'-'A',1;MC '\'-1,1;MC '3',1;MC '3',1;MC 'm',1] white [MC '\'-'A',1;MC '\'-1,1;MC '3',1;MC '7',1;MC 'm',1] getrand int array(0) [ int v(0), ptr(200) char buff(2000), nl(1) nl(0) = 10 if linux system "./rand" else system "rand.exe" readfile("rand.out",buff,2000) split ptr,buff,nl int i while i<100 [ atoi(ptr(i),v) array(i) = v(0) i=i+1 ] ] int linux main [ pl"";ps "deathrow.101a.tc - lrb - 2/3/23";pl"" char tcbuff(40),os(30) getproperty "pps/version.prop","os =",tcbuff,40,"..." strcpy os,tcbuff if (index(os,strlen(os),"Linux",5)) linux=1 int array(100) getrand array int n;n=100 int i,j,tried_count,fail,tfail int sims printf "%cHow many simulations do you want (e.g. 1000) : ", 10 sims=gn int icontents char buff(100) cdate(buff) printf "%cStart time : %s%c",10,buff,10 while j<=sims-1 [ // do sims times i=0;fail=0 while ((i<=n-1)*(fail==0)) [ // do up to n times tried_count=0 icontents=array(i) // get bucket labeled i's contents // while contents is not = inmate # and tried_count < n/2 while ((icontents!=i)*(tried_count