## Posted By

cmm7825 on 05/20/10

# Problem 11

/ Published in: Perl

`#!/usr/bin/perluse strict;use warnings; open INFILE, "<11.in"; my (@a, @tmp, \$result);my \$max = 0; while(<INFILE>){        @tmp = split;        push @a, [ @tmp ];} for my \$r (0..\$#a){    for my \$c (0..\$#{\$a[\$r]}){        #up        if(\$r >= 3){           \$result = \$a[\$r][\$c]*\$a[\$r][\$c-1]*\$a[\$r][\$c-2]*\$a[\$r][\$c-3];           \$max = \$result if \$result > \$max;        }        #left        if(\$c >= 3){           \$result = \$a[\$r][\$c]*\$a[\$r-1][\$c]*\$a[\$r-2][\$c]*\$a[\$r-3][\$c];           \$max = \$result if \$result > \$max;        }        #back diagonal        if(\$c >= 3 && \$r >= 3){           \$result = \$a[\$r][\$c]*\$a[\$r-1][\$c-1]*\$a[\$r-2][\$c-2]*\$a[\$r-3][\$c-3];           \$max = \$result if \$result > \$max;        }        #forward diagonal        if(\$r >= 3 && \$c <= \$#{\$a[\$r]}-3){           \$result = \$a[\$r][\$c]*\$a[\$r-1][\$c+1]*\$a[\$r-2][\$c+2]*\$a[\$r-3][\$c+3];           \$max = \$result if \$result > \$max;        }    }} print "\$max\n"; close INFILE;`