I have an array A() consisting of fixed number of rows and two columns. The first and second column in each row are numbers. For example, elements of matrix A() are:
A(1,1)=1
A(1,2)=2
A(2,1)=3
A(2,2)=4
A(3,1)=4
A(3,2)=5
A(4,1)=6
A(4,2)=7
A(5,1)=7
A(5,2)=1
A(6,1)=7
A(6,2)=4
I want to create groups by combining the rows such that, the 2nd column of one row is equal to the 1st column of any other row. If the 2nd column of the row just combined is equal to 1st column of any other row, that is also appended to the result obtained before. For example, the result would be
1) 1 2
2) 3 4 4 5 (that means 3-4 and 4-5 or 3-4-5)
3) 6 7 7 1
4) 7 4
There are many possibilities of combining. For example, another combination can be:
1) 1 2
2) 3 4 4 5
3) 6 7 7 4
4) 7 1
Third possible combination:
1) 1 2 (row1 having 2 columns)
2) 3 4 (row2 having 2 columns)
3) 7 4 4 5 (row3 having 4 columns)
4) 6 7 7 1 (row 4 having 4 columns)
I would like to have these results in an array (each number as one column for each row as shown above in the 3rd combination). I think if we obtain the 1st Array (the first combination), the other 2 can be obtained by manipulation and checking the numbers.
It would be nice to have all possible combinations in 1 big array, But I should also know how many elements (or rows) exist for each combination. I am open to suggestions as to how I can have multiple combinations, either in 1 big array or different arrays.
Kindly make this program as simple as possible as far as possible only using if and for statements. Dimension of array A starts from 1 and total number of rows in A are Ubound (A).
If anything is not clear please inform me.
Thanks.
## Deliverables
1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done.
2) Deliverables must be in ready-to-run condition, as follows (depending on the nature of the deliverables):
a) For web sites or other server-side deliverables intended to only ever exist in one place in the Buyer's environment--Deliverables must be installed by the Seller in ready-to-run condition in the Buyer's environment.
b) For all others including desktop software or software the buyer intends to distribute: A software installation package that will install the software in ready-to-run condition on the platform(s) specified in this bid request.
3) All deliverables will be considered "work made for hire" under U.S. Copyright law. Buyer will receive exclusive and complete copyrights to all work purchased. (No GPL, GNU, 3rd party components, etc. unless all copyright ramifications are explained AND AGREED TO by the buyer on the site per the coder's Seller Legal Agreement).
## Platform
Visual Basic 6, Windows XP