PDA

View Full Version : List all possible combinations



nimi-e
12-04-2012, 01:24 PM
Hi all,
I have a tough one..

I have a table with 16 rows (1-16) and 3 columns (a,b,c)
Each row can must have at least one of the three but may get more than one.

I want to make a code that will generate a list that will show all possible combinations.

Here is an example:

A B C
1 a b c
2 a b
3 a
4 a
5 a
6 a
7 a
8 a
9 a
10 a
11 a
12 a
13 a
14 a
15 a
16 a




So, from this example table there are 6 possible combinations and they are:
1 aaaaaaaaaaaaaaaa (16 times a)
2 abaaaaaaaaaaaaaa (a from the first line, b from second and 14 times a)
3 bbaaaaaaaaaaaaaa
4 baaaaaaaaaaaaaaa
5 caaaaaaaaaaaaaaa
6 cbaaaaaaaaaaaaaa

I know that if all 16 rows will have all 3 letters, I will get 45,000,000 different options, but in reality, I will use only a MAX of 20,000 at a run.

The a,b,c will be filled by hand, the code will need to make the list of the different combinations.

Any idea on how to solve this?

thank you all in advance!!!
Nimi