0

I'm using C#.

I have n number of lists that contain x number of ints.

How can I write a recursive method to give me all the combinations of these integers?

I want to use a class to move the data around because I'm not sure if you can have lists of lists. So if i have a class

 public class IdContainer 

that has

 public List<int> Id's

Each 'combination' should have n number of ints in it. So if I have 4 Lists as input each combination has 4 ints.

I want to have a method

public List<IdContainer> RecurseThroughIds(List<IdContainer> lists)

that will return the combinations of Id's

So for example if i had four lists

**List 1**
10

**List 2**
15
17

**List 3**
34
38

**List 4**    
44
45
46

I would have 12 different combinations (I believe)..

10
15
34
44

10
15
34
45

10
15
34
46

those would be the first 3 combinations

I cant wrap my head around a base case for this problem. I know this is fairly straight forward and not a difficult problem but i am struggling with it right now.

user1977591
  • 211
  • 1
  • 4
  • 22

0 Answers0