July 28th, 2010, 12:11 AM
[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.
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 as ArrayList).Add("Hello");
(MainArray as ArrayList).Add("Hello2");
(MainArray as ArrayList).Add("***");
Console.WriteLine(" hello item" + MainArray.IndexOf("***") +"does not exist");
July 28th, 2010, 04:14 AM
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.
Click Here to Expand Forum to Full Width