generate all permutations possible? (twist)

From: Date: Thu, 03 Apr 2003 23:59:09 +0000
Subject: generate all permutations possible? (twist)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-142220@lists.php.net to get a copy of this message
Hi Folks, 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

« previous php.general (#142220) next »