We have a matrix a(i,j) with i:1:M and j:1:N
We want to calculate the sum of all column combinations of N elements each from a distinct column and store them in a new array/matrix. This new matrix/array will have M^N elements. We need to also store which combination yeild this sum.
suppose M=3 and N=4
a = [1,2,3,4;5,6,7,8;9,10,11,12]
a(1,1)+a(1,2)+a(1,3)+a(1,4)–> sum of first element of every column
a(1,1)+a(2,2)+a(1,3)+a(1,4)–> sum of first element of column 1, 3 and 4 and 2nd element of column 2
a(1,1)+a(3,2)+a(1,3)+a(1,4)–> sum of first element of column 1, 3 and 4 and 3rd element of column 2
.
There will be 3^4 combinations.
The goal is to find out which sum combination yields the maximum and be able to report the location of elements of that combination in the main matrix a.
Best Answer