- #1
intervoxel
- 195
- 1
- TL;DR 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).
I need an optimized code that gives all the 720 random permutations:
Thanks for any answer.
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.