Connecting Tech Pros Worldwide Forums | Help | Site Map

All combination

Newbie
 
Join Date: Oct 2008
Posts: 1
#1: Oct 27 '08
hi there,

i have a huge problem. I have x (selected during runtime) stringsarrays with y values (selected during ruintime, too) each. Now i need a algorithm, which searches all possible combinations of the y stringarrays.

Example (input fom user)

string[] para1 = {"A1","A2"};
string[] para2 ={"B1","B2"" ,"B3"};
string[] para3 ={"C1","C2","C3"};

A1,B2,C3
A2,B1,C1
etc....

Thanks for you help
tlhintoq's Avatar
Moderator
 
Join Date: Mar 2008
Location: Arizona, USA
Posts: 1,763
#2: Oct 28 '08

re: All combination


Quote:

Originally Posted by Slowmo

hi there,

i have a huge problem. I have x (selected during runtime) stringsarrays with y values (selected during ruintime, too) each. Now i need a algorithm, which searches all possible combinations of the y stringarrays.

Example (input fom user)

string[] para1 = {"A1","A2"};
string[] para2 ={"B1","B2"" ,"B3"};
string[] para3 ={"C1","C2","C3"};

A1,B2,C3
A2,B1,C1
etc....

Thanks for you help

Posting tips about asking for entire solutions.

I suggest a little bit of google searching about "calculating combinations and permutations" followed by some attempts on your own. Don't search for a code solution that does the work for you. Search for an understanding of the concepts behind combinations, then work up code that achieves your needs.

How would you do it on paper? If you were going to figure out all the combinations how would you write them all out?

A1, B1, C1
A1, B1, C2
A1, B1, C3
[...]
A1, B2, C1
A1, B2, C2
[...]

Now take a stab at the code that would follow this same pattern of behavior.

Regards,
tlhIn'toQ
Reply