permuting a string (was Re: Speed)

Beat Cornaz B.Cornaz at gmx.net
Tue Sep 2 14:45:30 EDT 2014


Mon, 1 Sep 2014 19:35:31 -0500
From: Geoff Canyon <gcanyon at gmail.com>

> I have a set of code that seems to do the trick. It takes as an argument the number of each element to permute.

Great, Geoff, this works fine. Quite clever thinking :-)


Mon, 1 Sep 2014 19:47:58 -0500
From: Geoff Canyon <gcanyon at gmail.com>

> I think this is faster for many arguments. It might be slower for others.

Your right. The only thing with this script is, that it sometimes generates too many permutations. E.g. 111223 as input is ok. But 1112223 generates too many permutations. 11122233 is ok again.
I haven't figured out why. For the time being I appended a deletion of duplicates, and the right number of Permutations comes out. But it slows the script down, enough to make it slower than the one you posted just before (the long one).
It's a pity, because even in generating too many permutations, this last script is faster with large input strings than the other scripts. I'll have a look if I can find where it sometimes goes wrong.

Geoff, thanks again, I really appreciate your work and input, as well as the way you think. Very inspiring :-)

Cheers, Beat


More information about the use-livecode mailing list