Re: permuting a string (was Re: Speed)

2014-09-04 Thread Beat Cornaz
Wed, 3 Sep 2014 08:56:11 -0500 Geoff Canyon wrote : > Gah, I forgot one stinkin' line: > put isNewElement into wasNewElement That does the JOB :-) I was playing around with deleting duplicate perms inside the handler, which worked, but Geoff's solution (correct script) is much faster.

Re: permuting a string (was Re: Speed)

2014-09-03 Thread Geoff Canyon
On Tue, Sep 2, 2014 at 1:45 PM, Beat Cornaz wrote: > Mon, 1 Sep 2014 19:47:58 -0500 > From: Geoff Canyon > > > 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. 1

Re: permuting a string (was Re: Speed)

2014-09-02 Thread Beat Cornaz
Mon, 1 Sep 2014 19:35:31 -0500 From: Geoff Canyon > 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 > I think this is

Re: permuting a string (was Re: Speed)

2014-09-01 Thread Geoff Canyon
On Mon, Sep 1, 2014 at 10:32 AM, Beat Cornaz wrote: > This is my fastest script so far : > I think this is faster for many arguments. It might be slower for others. I removed the dependency on an external routine for removing duplicates. It also removes duplicates only when needed, and event the

Re: permuting a string (was Re: Speed)

2014-09-01 Thread Geoff Canyon
I have a set of code that seems to do the trick. It takes as an argument the number of each element to permute. So for your examples: On Mon, Sep 1, 2014 at 10:32 AM, Beat Cornaz wrote: > On my computer : > Input : 1112223334568320 mSec > Input : 123358 m

Re: permuting a string (was Re: Speed)

2014-09-01 Thread Beat Cornaz
Sat, 30 Aug 2014 09:01:16 -0400 From: Geoff Canyon > This was my initial thought as well, but I didn't like having to work > line-by-line on (potentially) large sets of lines from the initial > not-duplicate set of permutations. Doing the dupes first is weirder > conceptually, but it means that

Re: permuting a string (was Re: Speed)

2014-08-30 Thread Geoff Canyon
Gah -- now I'm not convinced that my way will work at all. I'll test and reply later. On Sat, Aug 30, 2014 at 8:19 AM, Geoff Canyon wrote: > > On Sat, Aug 30, 2014 at 7:24 AM, Beat Cornaz wrote: > >> Sat, 30 Aug 2014 Geoff wrote : >> >> > Used Alex's code to generate a list of the permutatio

Re: permuting a string (was Re: Speed)

2014-08-30 Thread Geoff Canyon
On Sat, Aug 30, 2014 at 7:24 AM, Beat Cornaz wrote: > Sat, 30 Aug 2014 Geoff wrote : > > > Used Alex's code to generate a list of the permutations of all the > characters that were duplicates. > > Substituted in unique characters for each instance of the duplicates. > > Ran my permutation code

Re: permuting a string (was Re: Speed)

2014-08-30 Thread Beat Cornaz
Sat, 30 Aug 2014 Geoff wrote : > Used Alex's code to generate a list of the permutations of all the characters > that were duplicates. > Substituted in unique characters for each instance of the duplicates. > Ran my permutation code on the rest of the characters, with the addition of > the dup

Re: permuting a string (was Re: Speed)

2014-08-29 Thread Geoff Canyon
On Wed, Aug 27, 2014 at 9:33 AM, Beat Cornaz wrote: > So, getting rid of the duplicates inside the script is quite important. I > still don't see yet how I can do that in Geoff's script (I will look into > that again, as soon as I can find a little time). If we can get that to > work, I think we'

Re: permuting a string (was Re: Speed)

2014-08-28 Thread Beat Cornaz
Thanks Alex, I will mail you off-list about the order of elements in the input and provide some examples. And thanks for the correction of your script. Seems to work fine now. I should have seen that one myself, but it was a bit late last night, sorry :-) Alex, you've explained the recursive f

Re: permuting a string (was Re: Speed)

2014-08-27 Thread Alex Tweedly
On 27/08/2014 23:02, Alex Tweedly wrote: I'll have a go at serializing this code - hopefully tonight (i.e. starting now and not getting myself tied up in knots with it :-) Here's a serialized version. Not as fast as I had hoped - it's about twice as fst as the recursive vesion, but that mean

Re: permuting a string (was Re: Speed)

2014-08-27 Thread Alex Tweedly
(second reply ..) On 27/08/2014 21:15, Beat Cornaz wrote: Alex wrote : Recursive scripts is something I know in principle about, but never have used them before. They are quite compact, but I find it hard to follow, especially as your variables are emptied in each new entry into the script (f

Re: permuting a string (was Re: Speed)

2014-08-27 Thread Alex Tweedly
I'm going to reply 2 or 3 separate answers ... otherwise it will get confusing :-) Sorry if this overloads anyone trying to delete or ignore the thread message by message. On 27/08/2014 21:15, Beat Cornaz wrote: As for the Duplicates : Alex wrote : permut() is the optimized version - optimi

Re: permuting a string (was Re: Speed)

2014-08-27 Thread Beat Cornaz
Alex wrote : >To make it faster, it *should* be serialized, so that it isn't actually >recursive; that should be quite easy (but will make the code much less > easy to read or understand, so I haven't done it yet). If you think it's > worth pursuing, let me know and I'll have a go at unrollin

Re: permuting a string (was Re: Speed)

2014-08-27 Thread Alex Tweedly
On 27/08/2014 14:33, Beat Cornaz wrote: So, getting rid of the duplicates inside the script is quite important. I still don't see yet how I can do that in Geoff's script (I will look into that again, as soon as I can find a little time). If we can get that to work, I think we'll have a winner

Re: permuting a string (was Re: Speed)

2014-08-27 Thread Beat Cornaz
Thanks Peter, your script works, but is in the same speed region as my original script, with the added disadvantage that it can't go beyond 9 chars. As for the duplicate elements : I did the same before - make all the possible permutations and then delete the duplicate ones. But as Geoff rightl

Re: permuting a string (was Re: Speed)

2014-08-26 Thread Peter M. Brigham
A tune-up on the earlier solution to listing permutations of a string. Obviously, no need to load an array with the values of the characters, just use "char c of tString". Also, if tString contains duplicate letters then there will be duplicate entries in the output, so those should be stripped