1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Programming Combinations of a string array

Discussion in 'C#' started by ang, Jun 2, 2006.

  1. ang

    ang New Member

    Joined:
    Jun 1, 2006
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  2. coderzone

    coderzone Super Moderator

    Joined:
    Jul 25, 2004
    Messages:
    734
    Likes Received:
    37
    Trophy Points:
    0
    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.
     
  3. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,293
    Likes Received:
    365
    Trophy Points:
    83
    Please read [thread=168]Before you make a query[/thread].
     
  4. dotnetrobert.com

    dotnetrobert.com New Member

    Joined:
    Nov 30, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hope this Link Helps

    <<Self promotion link dropped.>>
     
    Last edited by a moderator: Dec 1, 2007

Share This Page