fork download
  1. // written in the D programming language
  2. import std.algorithm;
  3. import std.array;
  4. import std.random;
  5. import std.range;
  6. import std.stdio;
  7.  
  8. void main ()
  9. {
  10. immutable int n = 3;
  11. immutable int steps = 10_100 * n ^^ n;
  12. int [n] p;
  13. int [int [n]] d;
  14. foreach (step; 0..steps)
  15. {
  16. p[] = n.iota.array;
  17. foreach (i; 0..n)
  18. {
  19. int j = uniform (0, n);
  20. swap (p[i], p[j]);
  21. }
  22. d[p] += 1;
  23. }
  24. writefln ("%(%s %s\n%)", d);
  25. }
  26.  
Success #stdin #stdout 0.11s 2732KB
stdin
Standard input is empty
stdout
[1, 2, 0] 50877
[0, 2, 1] 50543
[2, 0, 1] 40462
[2, 1, 0] 40214
[0, 1, 2] 40383
[1, 0, 2] 50221