On Tue, Aug 26, 2014 at 1:57 PM, Peter M. Brigham <pmb...@gmail.com> wrote:

> A followup on how to handle duplicate characters in the permuting
> algorithm. The following seems to work, not sure how it will scale. tString
> can contain any characters -- duplicates, digits, spaces, whatever.
>

I don't think this removes/avoids the duplicates that result from duplicate
characters. For example, permute("abb") returns:

bba

bba

bab

abb

bab

abb

When it should return:

bba

bab

abb

I haven't come up with any algorithm myself to do this other than to
generate the first list, set the indices of an array to the results, then
get the keys of the array. It would be fairly simple to do in the initial
P2 routine, but wouldn't scale at all the way it should. For example,
finding all 11 character permutations of "abbbbbbbbbb" should take a small
fraction of a second, but would actually take close to ten seconds.
_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to