- #1

- 195

- 1

- Summary:
- Algorithm do find all random permutations of n=[0,6)

**Summary:**Algorithm do find all random permutations of n=[0,6)

Hi,

The following algorithm gives 6 out of the 720 random permutations of integers in the range [0, 6).

Code:

```
t=0..5 // permutation
i=0..5 // sequence index
n = (t + i) % 6; // % is the mod operator
n = n*n % 11; // 11 is prime
n += n>>3; // >> is the bit shift right operator
n = n & 7; // & is the bitwise AND operator
```

I need an optimized code that gives all the 720 random permutations:

Code:

```
t=0..719 // permutation
i=0..5 // sequence index
n = f(t, i);
```

Thanks for any answer.