SHARE
TWEET

244 bytes

a guest Jun 23rd, 2015 261 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int[]f(int k,int t){int q,m,i,h,f,d[]=new int[k],b[]=d.clone();for(;t-->0;){q=k;d[q*=Math.random()]++;m=0;i=q;h=1;f=0;if(d[q]>1){for(;;){if(i<0){i=k-1;h=-1;}if(d[i%k]>0){m++;d[i%k]=0;}else{if(f>0)break;h*=-1;i=q;f=1;}i+=h;}b[m-1]++;}}return b;}
  2.  
  3.  
  4. //
  5.  
  6. int[]f(int k,int t){
  7.         int q,m,i,h,f,d[]=new int[k],b[]=d.clone();
  8.         for(;t-->0;){
  9.                 q=k;d[q*=Math.random()]++;
  10.                 m=0;i=q;h=1;f=0;
  11.                 if(d[q]>1){
  12.                         for(;;){
  13.                                 if(i<0){i=k-1;h=-1;}
  14.                                 if(d[i%k]>0){m++;d[i%k]=0;}
  15.                                 else{if(f>0)break;h*=-1;i=q;f=1;}
  16.                                 i+=h;
  17.                         }
  18.                         b[m-1]++;
  19.                 }
  20.         }
  21.         return b;
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top