LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

permutations of a 6! numerically

Solved!
Go to solution

Is it possible to change it from an array of say A B C D E F  to a word as in:- ABCDEF as a single element?

 

0 Kudos
Message 41 of 57
(691 Views)

 


@John Pierson wrote:

Is it possible to change it from an array of say A B C D E F  to a word as in:- ABCDEF as a single element?


Yes, my second example does that. 😄

 


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
Message 42 of 57
(687 Views)

extra kudos for you my man!

0 Kudos
Message 43 of 57
(680 Views)

Very nice solution Christian.

 

🙂  Many kudos.

 

______________________________________________________________________
0 Kudos
Message 44 of 57
(657 Views)

Could have been fun, too bad late lunch on West Coast means slow on the draw.  At any rate, the OP has a solution so I do not have to worry about minor details like saving for 8.2. The classic recursion solution is elegant (like most recursive solutions), but native recursion (in LV9+) is slow, and VI server recursion is downright glacial.  I think the physicist side of DFGray showed up, rolling the dice is a simple-yet-effective treatment in these cases, I would probably have been putting Riffle to good use here.

 

Altenbach's solution is (needless-to-say) masterfully efficient, I only have a few quibbles.  It assumes the elements are distinct, but oftentimes, especially with letters, elements can be repeated.  Second, while there is considerable in-placeness, it is often not the best idea to be carrying around all possible combinations since that can become quite a large number in a hurry.

 

So, given this good excuse to dust off Knuth's book, and as an added bonus implement a 700 year old algorithm, here is my take.  Shamelessly LV9.0 (or at least 8.6 for the IPE and conditional For Loops).  This routine is seriously in-place, each time it is run it generates the next permutation given the previous one.  Using for example the letters 'aab' it returns only three permutations instead of six.

 

18403i9E6A43238BFF8228

Download All
Message 45 of 57
(641 Views)

Oops.  seemed to attach same file twice last time.  Here is the VI which uses a while loop to find all permutations.  Better hurry before altenbach notices...

 

Message 46 of 57
(636 Views)

What's the difference between the two attachments?

 

EDIT: Nevermind, just saw your new post... 😉


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 47 of 57
(634 Views)

Post collision earlier.

0 Kudos
Message 48 of 57
(628 Views)

Looks good. Do you have a link to the algorithm?

 

(One minor flaw: an empty string input should probably give an empty array as output.)


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 49 of 57
(612 Views)

 


altenbach wrote:

(One minor flaw: an empty string input should probably give an empty array as output.)


 

Quick fix:

In the TRUE case, check for "empty string?" and wire the output to the tunnel, replacing the boolean diagram constant.


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
Message 50 of 57
(608 Views)