Dec 27, 2009 at 10:43pm UTC
Hi I had a headache in creating an algorithim to determine the nos of possible combination of nos 2 in the 2 dimensional array here is the example
in this example i had a 2 dimensional array 5 columns and 4 rows; I want to get the combiniations of three 2's.
20000
00200
00200
22000
in this case we can say that we had 4x of three 2's
output will be
1st
column 0; row 0
column 1; row 3
column 2; row 1
2nd
column 0; row 3
column 1; row 3
column 2, row 1
3rd
column 0; row 0
column 1; row 3
column 2, row 2
4th
column 0; row 3
column 1; row 3
column 2, row 2
If you have time please help me or give me some codes example of the algorithim that makes these output and checking
Any response will be appreciated
Thank you very much
Dec 28, 2009 at 5:57am UTC
The two-dimensionality of the array is a distraction. What you want is a list of coordinates, or indices, into the matrix.
So, given your array of
20000
00200
00200
22000
you can extract a list of five coordinate pairs:
(c,r) = (0,0) (2,1) (2,2) (0,3) (1,3)
Now your problem is simplified. List all combinations of those coordinate pairs taken by threes.
Hope this helps.
Dec 28, 2009 at 9:47pm UTC
Hi thanks for your replay. My problem is not that simple. It is more complicated than that and much better if you can give me a sample algo or actual source code.
I forgot to add a rules in making the algorithm. The rules is
"If there is two or more nos 2 in any column only 1 of them is used to make each combinations"
Thanks again
I still need help