Hi,
In the code below I have 2 nested loops, with the inner loop starts from the index of the outer loop till the end. You can think of it as I am trying to find ll the combinations. So if we have 'm' rows, we will have m(m+1)/2 possible combination. I want to map 'i' & 'g' to indices that covers that range starting from 0 to ( (m(m+1)/2) - 1).
const int m = 5;
int arr[m(m+1)/2];
for( int g = 0; g < m; g++)
{
for(int i = g; i < m; i++)
{
// we have here 15 possible combination, index should start from 0 to 14
// and i want to deduce index from i,g and m
arr[index] = index;
}
}
I know that this is a mathmatical problem more than a problem in coding but I am looking for your help
thanks!