I’m trying to generate random permutations of an 80-character fixed string in C. Much to my dismay, the system I’m working on lacks strfry(). What’s the best way for me to generate a random permutation of this string? Since this will be looped over approx. 100,000 times, performance is an issue.
I’m trying to generate random permutations of an 80-character fixed string in C. Much
Share
Just use the Open Source GLIBC implementation, as found by Google Code.
You might want to change the GLIBC specific data types to something more generic.
This code uses the Fisher-Yates shuffle which is actually quite easy to implement by yourself, and very efficient.