I have the following problem: I need to create a table, which is combination of values coming from sets. The cardinality of the elements in the set is unknown, and may vary from set to set, the domain of the values is unknown, and may as well vary from set to set. The elements in the set are non-negative, at least two elements are within a set. Here follows an example:
- SET_A = { 0, 1, 2 }
- SET_B = { 0, 1 }
- SET_C = { 0, 1 }
The result should contain the following rows (order is not a constraint):
TABLE:
- | 0 0 0 |
- | 0 0 1 |
- | 0 1 0 |
- | 0 1 1 |
- | 1 0 0 |
- | 1 0 1 |
- | 1 1 0 |
- | 1 1 1 |
- | 2 0 0 |
- | 2 0 1 |
- | 2 1 0 |
- | 2 1 1 |
Does anybody know which is the Mathematics behind this problem? I tried to look at Multiset problems, logic tables, combinatorics. Many of the definitions that I found have similarities to my problem, but I can't isolate anything in the literature that I have accessed so far. Once I have a reference definition I can think of coding it, but now I just got lost in recursive functions and terrible array-index games. Thanks.
EDIT: Question was proposed already at: C# Permutation of an array of arraylists?