






import os





def 	_lowerCAmelCase       (    _lowerCAmelCase )						->	Union[str, Any]:


						'''simple docstring'''






						__snake_case				=		len(grid[0] )
						__snake_case				=		len(_lowerCamelCase )

						__snake_case				=		0
						__snake_case				=		0
						__snake_case				=		0

						# Check vertically, horizontally, diagonally at the same time (only works
						# for nxn grid)
						for i in range(_lowerCamelCase ):
												for j in range(n_rows - 3 ):
																		__snake_case				=		grid[j][i] * grid[j + 1][i] * grid[j + 2][i] * grid[j + 3][i]
																		__snake_case				=		grid[i][j] * grid[i][j + 1] * grid[i][j + 2] * grid[i][j + 3]

																		# Left-to-right diagonal (\) product
																		if i < n_columns - 3:
																								__snake_case				=		(
																								    grid[i][j]
																								    * grid[i + 1][j + 1]
																								    * grid[i + 2][j + 2]
																								    * grid[i + 3][j + 3]
																								)

																		# Right-to-left diagonal(/) product
																		if i > 2:
																								__snake_case				=		(
																								    grid[i][j]
																								    * grid[i - 1][j + 1]
																								    * grid[i - 2][j + 2]
																								    * grid[i - 3][j + 3]
																								)

																		__snake_case				=		max(
																		    _lowerCamelCase      ,	_lowerCamelCase      ,	_lowerCamelCase      ,	_lowerCamelCase )
																		if max_product > largest:
																								__snake_case				=		max_product

						return largest





def 	_lowerCAmelCase       (    )						->	Any:


						'''simple docstring'''






						__snake_case				=		[]
						with open(os.path.dirname(_lowerCamelCase ) + "/grid.txt" ) as file:
												for line in file:
																		grid.append(line.strip("\n" ).split(" " ) )

						__snake_case				=		[[int(_lowerCamelCase ) for i in grid[j]] for j in range(len(_lowerCamelCase ) )]

						return largest_product(_lowerCamelCase )


if __name__ == "__main__":
	print(solution())









def 	_lowerCAmelCase       (    _lowerCAmelCase )						->	int:


						'''simple docstring'''






						__snake_case				=		abs(_lowerCAmelCase )
						__snake_case				=		0
						while n > 0:
												res += n % 10
												n //= 10
						return res





def 	_lowerCAmelCase       (    _lowerCAmelCase )						->	int:


						'''simple docstring'''






						__snake_case				=		abs(_lowerCAmelCase )
						return n if n < 10 else n % 10 + sum_of_digits(n // 10 )





def 	_lowerCAmelCase       (    _lowerCAmelCase )						->	int:


						'''simple docstring'''






						return sum(int(_lowerCAmelCase ) for c in str(abs(_lowerCAmelCase ) ) )





def 	_lowerCAmelCase       (    )						->	None:


						'''simple docstring'''






						from collections.abc import Callable
						from timeit import timeit

						def benchmark_a_function(_lowerCAmelCase      ,	_lowerCAmelCase ) -> None:
												__snake_case				=		F'''{func.__name__}({value})'''
												__snake_case				=		timeit(F'''__main__.{call}'''      ,	setup="import __main__" )
												print(F'''{call:56} = {func(_lowerCAmelCase )} -- {timing:.4f} seconds''' )

						for value in (26_2144, 1125_8999_0684_2624, 126_7650_6002_2822_9401_4967_0320_5376):
												for func in (sum_of_digits, sum_of_digits_recursion, sum_of_digits_compact):
																		benchmark_a_function(_lowerCAmelCase      ,	_lowerCAmelCase )
												print()


if __name__ == "__main__":
	import doctest

	doctest.testmod()
	benchmark()





