CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2010

    [RESOLVED] Two Dimensional ArrayList and finding combinations Questions

    Ok here is what i want to do.

    I have a one dimensional arraylist holding 100 numbers that are all unique. i would like to loop through all those numbers and group them into sets of 5 which would leave me 20 groups.

    but here is the catch, no group can contain the same number twice and each group has to be unique when compared to the other groups.

    each group can contain four of the same numbers of another group but not 5.
    like so

    key 0 --- value(100,200,500,1000,20)
    key 1 -- value(200,999,100,1000,20)
    key 2 ----value(500,999,100,80,50)

    basically i need to find every possible combination for each group. a matrix if you will.

    how can achieve this? using a recursive function with indexof?

    ArrayList MainArray = new ArrayList();

    MainArray.Add(new ArrayList());
    MainArray.Add(new ArrayList());

    (MainArray[1] as ArrayList).Add("Hello");
    (MainArray[1] as ArrayList).Add("Hello2");
    (MainArray[2] as ArrayList).Add("***");
    Console.WriteLine(" hello item" + MainArray.IndexOf("***") +"does not exist");

  2. #2
    Join Date
    Jul 2010

    Re: Two Dimensional ArrayList and finding combinations Questions

    found a solution to my problem

    Permutations, Combinations, Variations and lots of reading. Probably going with LINQ solution.

    this helped me get on the right track.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.