I'm struggling with a permutation problem.
I want to take a set of characters (for example "012345678ABCDEF") and generate all permutations of length N, allowing characters to be repeated. For example, I could use this algorithm to generate all HTML hex colors by passing:
generatePermutations("012345678ABCDEF",6)
Granted, this example would output some 16,777,215 items, but it would be a handy thing.
Note that I could get these color values by running from 0 to FFFFFF in hex, but I am looking for something more general so I can play with anagrams, etc.
I have seen some algorithms that generate permutations, but I don't want all permutations of "012345678ABCDEF", I just want all 6-digit permutations.
I have searched all over for algorithms, and have beat my head against it, but it is just escaping me. Can anyone help?
thanks,
michael
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php