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 = 4;
  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 1.31s 2732KB
stdin
Standard input is empty
stdout
[0, 2, 1, 3] 101017
[0, 1, 3, 2] 101144
[1, 0, 3, 2] 151325
[3, 0, 1, 2] 81097
[3, 2, 0, 1] 101275
[2, 3, 0, 1] 110811
[1, 2, 3, 0] 141461
[0, 1, 2, 3] 101129
[2, 1, 0, 3] 90904
[3, 1, 0, 2] 91372
[0, 2, 3, 1] 141320
[3, 2, 1, 0] 100997
[0, 3, 2, 1] 91327
[3, 0, 2, 1] 90743
[3, 1, 2, 0] 80384
[0, 3, 1, 2] 111424
[2, 0, 1, 3] 111194
[1, 3, 2, 0] 110692
[1, 3, 0, 2] 110917
[2, 3, 1, 0] 100812
[1, 2, 0, 3] 141214
[2, 1, 3, 0] 111493
[2, 0, 3, 1] 111077
[1, 0, 2, 3] 100471