Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C# (http://www.go4expert.com/forums/c-sharp/)
-   -   Programming Combinations of a string array (http://www.go4expert.com/forums/programming-combinations-string-array-t856/)

ang 2Jun2006 04:43

Programming Combinations of a string array
 
Hi,

I like to create hashtables from a string array haviong all possible combinations.

I guess i will give examples to better explain my problem.

suppose there is a string array which we call matrix in mathematics

1 2 3

4 5 6

7 8 9

Now the combinations should be cerated and each combination will go in one hashtable

(1,4,7) (1,4,8) (1,4,9) (1,5,7) (1,5,8) (1,5,9) (1,6,7) (1,6,8) (1,6,9) (2,4,7) (2,4,8) (2,4,9) (2,5,7) (2,5,8) (2,5,9)

(2,6,7) (2,6,8) (2,6,9) (3,4,7) (3,4,8) (3,4,9) (3,5,7) (3,5,8) (3,5,9)

(3,6,7) (3,6,8) (3,6,9)

Also the matrix can be of any dimension and not just 3*3 it can be of 3*2 or 4*5 or 4*4

Please help me writting the code in c# to generate the above combinations.

Thanks in advance.

coderzone 2Jun2006 14:54

Re: Programming Combinations of a string array
 
If I understand just take a 2 Dimensional array of (N x M) and initialize all to some impossible input (say -1) now nested loop through them to get the combination.

Can you put your code sample you are working on here.

shabbir 2Jun2006 16:16

Re: Programming Combinations of a string array
 
Please read Before you make a query.

dotnetrobert.com 1Dec2007 00:31

Re: Programming Combinations of a string array
 
Hope this Link Helps

<<Self promotion link dropped.>>


All times are GMT +5.5. The time now is 23:11.