Speed
Geoff Canyon
gcanyon at gmail.com
Tue Aug 26 23:08:09 EDT 2014
On Tue, Aug 26, 2014 at 1:57 PM, Peter M. Brigham <pmbrig at 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.
More information about the use-livecode
mailing list