Largest Product in MxN grid Given an MxN grid of numbers, find the greatest product of a length 4 subsequence in any row, column, or diagonal. Subsequences cannot wrap around (e.g. 5 1 2 3 in the row 1 2 3 4 5).

I/O can be anything reasonable: files, stdin/stdout, copy+pasting expressions/arguments, variables. (If I'm missing any esoteric I/O option, feel free to go ahead and post your solution anyways)
J, 26 chars

&gt;./,4*/\"1(,|:,]/.,]/.@|.)


Just an expression to which a rank 2 array could be appended.

,|:,]/.,]/.@|. takes the rank 2 array and concatenates 4 intermediate rank 2 arrays, the input's identity, transposition, and obliques, respectively. Here I feel like there's an uncomfortable amount of redundancy, because there are 2 ]s, 3 ,s, and 2 /.s... I can't think of a way to refactor those out.

&gt;./,4*/\"1 is just a straightforward maximum of each length 4 subsequence of each row of the newly made array, which of course corresponds to rows/columns/diagonals of the original.