def problem8(filename): """ Return the greatest product of five consecutive digits in given file which contains the 1000-digit number. >>> problem8('problem08.txt') 40824 """ lines, n = open(filename).readlines(), 5 matrix = [map(lib.convert_int, list(line.strip())) for line in lines] return lib.greatest_product_row(matrix, n)
def problem11(filename): """ >>> problem11('problem11.txt') 70600674 """ n = 4 lines = open(filename).readlines() matrix = [map(lib.convert_int, line.strip().split(' ')) for line in lines] d1, d2 = lib.greatest_product_diagonally(matrix, n) L = [lib.greatest_product_row(matrix, n), lib.greatest_product_col(matrix, n), d1, d2] L.sort() return L[-1]