From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
07-08-2010 11:04 AM
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?
07-08-2010 11:06 AM - edited 07-08-2010 11:06 AM
@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. 😄
07-08-2010 11:09 AM
extra kudos for you my man!
07-08-2010 12:12 PM
Very nice solution Christian.
🙂 Many kudos.
07-08-2010 03:52 PM - edited 07-08-2010 03:53 PM
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.
07-08-2010 04:19 PM - edited 07-08-2010 04:22 PM
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...
07-08-2010 04:20 PM - edited 07-08-2010 04:23 PM
What's the difference between the two attachments?
EDIT: Nevermind, just saw your new post... 😉
07-08-2010 04:23 PM
Post collision earlier.
07-08-2010 04:44 PM
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.)
07-08-2010 04:57 PM
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.