キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

combination code

hello i need the code for combinations for given string for eg if the input string is abcd then the o/p contains all 24 combinations pls help me
0 件の賞賛
メッセージ1/8
3,946件の閲覧回数

Hi jeshu,

 

this really sounds like homework. I think I saw that question before...

 

We will not do your homework here, but we will be happy to help for specific questions. So show what you have done before & tell where you have problems!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 件の賞賛
メッセージ2/8
3,944件の閲覧回数
actually i dont know the algorithm how to do this , i am searching for idea not whole code sir , i know something that we need to convert the string in to byte array then i am not getting any idea for what to do , pls help me this pro is coming for  tomorrow's test
0 件の賞賛
メッセージ3/8
3,939件の閲覧回数

Hi jeshu,

 

in the string palette you find a function to convert a string into an U8 array.

 

For the theory you may start here!

 

Good luck for tomorrow's test - I will now enjoy my Sunday evening スマイリー ウインク

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 件の賞賛
メッセージ4/8
3,935件の閲覧回数
This sounds like a job for recursion, unless you're limiting the input to only four characters.
Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 件の賞賛
メッセージ5/8
3,923件の閲覧回数

Hi jeshu

 

This is not a difficult code to make. I have already done this. 

Start like this. I hope you are familiar with the for loop!

So use 4 nested for loops to compare the individulal letters and finally write them in an array. Like you have ABCD. Take A from the first loop and use it to compare with all letters in 2nd loop. As soon as you get different letters in 2nd loop (like A and B), compare these 2 letters with all letters in loop number 3. when you get all 3 different letters from loop number 3 (like A , B , C), compare all the 3 with letters in the final loop. Finally , when you have all three different letters, write them in an array.  

 

Somil Gautam
Think Weird
0 件の賞賛
メッセージ6/8
3,900件の閲覧回数

Hi jeshu,

 

one more hint:

Try to adapt an recursive way of generating combinations:

1) start with 1 char -> one possibility (A)

2) add 2nd char and "insert" it before and after first char -> two additional possibilities (AB, BA)

3) add 3rd char and insert it in every possible position in each of the strings generated before -> 6 more possibilities (CAB, ACB, ABC, CBA, BCA, BAC)

4) add 4th char and repeat step 3 (DCAB, ADCB, ABCD, some more...)

5) do step 3 for all additional chars

 

This should be a nice exercise to learn how to use for loops, shift registers, building arrays and string functions スマイリー ウインク

Message Edited by GerdW on 11-09-2009 10:33 AM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 件の賞賛
メッセージ7/8
3,882件の閲覧回数

Ya, this is another way of doing it.

 

In the method of nested for loops, you can get 24 combinations only if all the letters in the string are different (because of comparison)

 

But in this method, of  insertion, you can get the combinations even if the letters are same in a given string. 

Somil Gautam
Think Weird
0 件の賞賛
メッセージ8/8
3,878件の閲覧回数