SEPA: A Simple, Efficient Permutation Algorithm
quickperm.org
quickperm.org
[1] Draft version of Knuth's Fascicle 2B: http://www.cs.utsa.edu/~wagner/knuth/fasc2b.pdf#page=5 (now page 319 of Volume 4A)
[2]: https://www.quora.com/How-would-you-explain-an-algorithm-tha...
void swap(char *s, int a, int b)
{
s[b] ^= s[a];
s[a] ^= s[b];
s[b] ^= s[a];
} function xorSwapTest(min, max) {
for (var i = min; i < max; i++) {
var a = i, b = i;
b ^= a;
a ^= b;
b ^= a;
if (a != i || b != i)
throw Error("Problem with " + i);
}
return true;
}