MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / solution

Function solution

project_euler/problem_011/sol1.py:71–85  ·  view source on GitHub ↗

Returns the greatest product of four adjacent numbers (horizontally, vertically, or diagonally). >>> solution() 70600674

()

Source from the content-addressed store, hash-verified

69
70
71def solution():
72 """Returns the greatest product of four adjacent numbers (horizontally,
73 vertically, or diagonally).
74
75 >>> solution()
76 70600674
77 """
78 grid = []
79 with open(os.path.dirname(__file__) + "/grid.txt") as file:
80 for line in file:
81 grid.append(line.strip("\n").split(" "))
82
83 grid = [[int(i) for i in grid[j]] for j in range(len(grid))]
84
85 return largest_product(grid)
86
87
88if __name__ == "__main__":

Callers 1

sol1.pyFile · 0.70

Calls 3

largest_productFunction · 0.85
splitMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected