Generalize Problem : Generate all possible combinations

From: rajsena (rajsena911_at_gmail.com)
Date: 11/08/04


Date: 8 Nov 2004 09:47:13 -0800

Hi,

I would really appreciate if somebody could help me with this problem

Problem: Need to generate All possible combinations for a N-bit number
wherein each position as a finite (1-6) possibilities.

Heres a simple example

Array1 { 1 2 3 }
Array2 { 4 5 }
Array3 { 6 7 }

Generate all possible combinations such that,

Number 3 bit

1 bit comes from array1
2 bit comes from array2
3 bit comes from array3

possible combinations

1 4 6
1 4 7
1 5 6
1 5 7
2 4 6
2 4 7 and so on....

I need to generalize this for a N bit number (determined at runtime)
where in each position is comes from an array of {1-6} possible
combinations.

Thanks,

- raj