Note ' http://projecteuler.net/index.php?section=problems&id=345 ' Please consider brutish solution to the example (quoted below) The algorithm rotates all !5 possible values into column 0 , and finds the maximum sum. This being j, and having rotated entire rows, it is easy to consider all columns. Since some of the permutations involve whole matrix rotations (a constant plus the permutation vector P, 5 | (i.5) +/ P ) the result appears once in each column. Specifically which !4 of all !5 rotations did I need? What is the answer in general?
Thank you, Dave---not yet a master of A.`C. (or of other stuffs). "We define the Matrix Sum of a matrix as the maximum sum of matrix elements with each element being the only one in his row and column. For example, the Matrix Sum of the matrix below equals 3315 (= 863 + 383 + 343 + 959 + 767)" ) a=: 7 53 183 439 863 a=:a,:497 383 563 79 973 a=:a, 287 63 343 169 583 a=:a, 627 343 773 959 943 $a=:a,767 473 103 699 303 5 5 $b=: ((i.!5) A. i.5)|."0 1"1 _ a 120 5 5 $c=: +/"2 b 120 5 >./,c NB. solution 3315 3315 +/ . = ,c NB. number of occurrences 5 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
