Question: I've been looking into combinations lately, I've tried various 3rd party solutions, and tried to get my head around it myself. Without success I might add.

I need to generate a 13 length string with all possible combinations of say.. int 0-2, I.E

```
0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0 0 0 0 0 2
0 0 0 0 0 0 0 0 0 0 0 1 0
... 
2 2 2 2 2 2 2 2 2 2 2 2 2

```

You probably get the drill, I'm aware I could just wrap this up in loops if I wanted a dirty solution. Any guidance or pointers are appreciated.

Answer: 
I can't help thinking of this as just adding number in a N-based numeric system (in your example a 3-base system).

I would write one method (if not already there in the framework or a library) that would allow you to switch bases. I.E:

```
String transformNumberFrom10BaseToXBase(int number, int base)

```

then just write a for loop (sorry, pseudo-c-like-code :) ):

```
for (int i = 0; i < base ^ 13; i++) {
    print transformNumberFrom10BaseToXBase(i, base)
}

```

Ok, hope that helps or give you an idea on how to solve it :)
I've written quickly function that returns list of permutations, so if you have not time to write your own method, you can use it. length is permutation length, max is maximum number (in your case, it would be 2)

```
    static List<int[]> getPermutationList(int length, int max)
    {
        List<int[]> perm_list = new List<int[]>();
        int[] perm = new int[length];
        for (int i = 0; i < length; ++i)
            perm[i] = 0;
        while(true)
        {
            for (int i = length - 1; ; --i)
            {
                if (i == -1)
                    return perm_list;
                if (perm[i] < max)
                {
                    perm[i]++;
                    for (int j = i + 1; j < length; ++j)
                        perm[j] = 0;
                    break;
                }

            }
            int[] perm_copy = new int[length];

            for (int i = 0; i < length; ++i)
            {
                perm_copy[i] = perm[i];
            }
            perm_list.Add(perm_copy);
        }
        return perm_list;
    }

```