






'''simple docstring'''



import os


def 				lowercase_					(     __A			:							Any      )							->   Tuple:



 """simple docstring"""




 lowercase       : List[str]						=len(grid[0]      )
 lowercase       : Union[str, Any]						=len(__A      )

 lowercase       : List[str]						=0
 lowercase       : Union[str, Any]						=0
 lowercase       : List[str]						=0

 # Check vertically, horizontally, diagonally at the same time (only works
 # for nxn grid)
 for i in range(__A      ):
  for j in range(n_rows - 3      ):
   lowercase       : Optional[Any]						=grid[j][i] * grid[j + 1][i] * grid[j + 2][i] * grid[j + 3][i]
   lowercase       : Optional[Any]						=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:
    lowercase       : str						=(
        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:
    lowercase       : List[Any]						=(
        grid[i][j]
        * grid[i - 1][j + 1]
        * grid[i - 2][j + 2]
        * grid[i - 3][j + 3]
    )

   lowercase       : Any						=max(
       __A       ,   __A       ,   __A       ,   __A      )
   if max_product > largest:
    lowercase       : List[str]						=max_product

 return largest


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



 """simple docstring"""




 lowercase       : Union[str, Any]						=[]
 with open(os.path.dirname(__A      ) + '''/grid.txt'''      ) as file:
  for line in file:
   grid.append(line.strip('''\n'''      ).split(''' '''      )      )

 lowercase       : Any						=[[int(__A      ) for i in grid[j]] for j in range(len(__A      )      )]

 return largest_product(__A      )


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











'''simple docstring'''



import unittest

from transformers.testing_utils import CaptureStdout
from transformers.tools.python_interpreter import evaluate


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



 """simple docstring"""




 return x + 2





class UpperCAmelCase_       (     unittest.TestCase					):




      """simple docstring"""




      def 					A__   (			self      :		Dict		)	->	List[Any]:


       '''simple docstring'''

       lowercase       : Optional[int]						='''x = 3'''
       lowercase       : Any						={}
       lowercase       : Union[str, Any]						=evaluate(UpperCAmelCase  ,   {}  ,   state=UpperCAmelCase		)
       assert result == 3
       self.assertDictEqual(UpperCAmelCase  ,   {'''x''': 3}		)

       lowercase       : str						='''x = y'''
       lowercase       : Optional[int]						={'''y''': 5}
       lowercase       : List[str]						=evaluate(UpperCAmelCase  ,   {}  ,   state=UpperCAmelCase		)
       # evaluate returns the value of the last assignment.
       assert result == 5
       self.assertDictEqual(UpperCAmelCase  ,   {'''x''': 5, '''y''': 5}		)






      def 					A__   (			self      :		str		)	->	Optional[int]:


       '''simple docstring'''

       lowercase       : Optional[int]						='''y = add_two(x)'''
       lowercase       : str						={'''x''': 3}
       lowercase       : List[str]						=evaluate(UpperCAmelCase  ,   {'''add_two''': add_two}  ,   state=UpperCAmelCase		)
       assert result == 5
       self.assertDictEqual(UpperCAmelCase  ,   {'''x''': 3, '''y''': 5}		)

       # Won't work without the tool
       with CaptureStdout() as out:
        lowercase       : Optional[Any]						=evaluate(UpperCAmelCase  ,   {}  ,   state=UpperCAmelCase		)
       assert result is None
       assert "tried to execute add_two" in out.out






      def 					A__   (			self      :		List[Any]		)	->	Optional[int]:


       '''simple docstring'''

       lowercase       : int						='''x = 3'''
       lowercase       : Dict						={}
       lowercase       : List[Any]						=evaluate(UpperCAmelCase  ,   {}  ,   state=UpperCAmelCase		)
       assert result == 3
       self.assertDictEqual(UpperCAmelCase  ,   {'''x''': 3}		)






      def 					A__   (			self      :		str		)	->	Tuple:


       '''simple docstring'''

       lowercase       : Optional[Any]						='''test_dict = {\'x\': x, \'y\': add_two(x)}'''
       lowercase       : str						={'''x''': 3}
       lowercase       : Tuple						=evaluate(UpperCAmelCase  ,   {'''add_two''': add_two}  ,   state=UpperCAmelCase		)
       self.assertDictEqual(UpperCAmelCase  ,   {'''x''': 3, '''y''': 5}		)
       self.assertDictEqual(UpperCAmelCase  ,   {'''x''': 3, '''test_dict''': {'''x''': 3, '''y''': 5}}		)






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


       '''simple docstring'''

       lowercase       : Optional[Any]						='''x = 3\ny = 5'''
       lowercase       : int						={}
       lowercase       : List[str]						=evaluate(UpperCAmelCase  ,   {}  ,   state=UpperCAmelCase		)
       # evaluate returns the value of the last assignment.
       assert result == 5
       self.assertDictEqual(UpperCAmelCase  ,   {'''x''': 3, '''y''': 5}		)






      def 					A__   (			self      :		Any		)	->	Tuple:


       '''simple docstring'''

       lowercase       : List[str]						='''text = f\'This is x: {x}.\''''
       lowercase       : Union[str, Any]						={'''x''': 3}
       lowercase       : Tuple						=evaluate(UpperCAmelCase  ,   {}  ,   state=UpperCAmelCase		)
       # evaluate returns the value of the last assignment.
       assert result == "This is x: 3."
       self.assertDictEqual(UpperCAmelCase  ,   {'''x''': 3, '''text''': '''This is x: 3.'''}		)






      def 					A__   (			self      :		Union[str, Any]		)	->	List[Any]:


       '''simple docstring'''

       lowercase       : Tuple						='''if x <= 3:\n    y = 2\nelse:\n    y = 5'''
       lowercase       : Union[str, Any]						={'''x''': 3}
       lowercase       : Any						=evaluate(UpperCAmelCase  ,   {}  ,   state=UpperCAmelCase		)
       # evaluate returns the value of the last assignment.
       assert result == 2
       self.assertDictEqual(UpperCAmelCase  ,   {'''x''': 3, '''y''': 2}		)

       lowercase       : Optional[Any]						={'''x''': 8}
       lowercase       : str						=evaluate(UpperCAmelCase  ,   {}  ,   state=UpperCAmelCase		)
       # evaluate returns the value of the last assignment.
       assert result == 5
       self.assertDictEqual(UpperCAmelCase  ,   {'''x''': 8, '''y''': 5}		)






      def 					A__   (			self      :		str		)	->	Optional[Any]:


       '''simple docstring'''

       lowercase       : List[str]						='''test_list = [x, add_two(x)]'''
       lowercase       : Any						={'''x''': 3}
       lowercase       : Tuple						=evaluate(UpperCAmelCase  ,   {'''add_two''': add_two}  ,   state=UpperCAmelCase		)
       self.assertListEqual(UpperCAmelCase  ,   [3, 5]		)
       self.assertDictEqual(UpperCAmelCase  ,   {'''x''': 3, '''test_list''': [3, 5]}		)






      def 					A__   (			self      :		Any		)	->	Tuple:


       '''simple docstring'''

       lowercase       : str						='''y = x'''
       lowercase       : Dict						={'''x''': 3}
       lowercase       : Tuple						=evaluate(UpperCAmelCase  ,   {}  ,   state=UpperCAmelCase		)
       assert result == 3
       self.assertDictEqual(UpperCAmelCase  ,   {'''x''': 3, '''y''': 3}		)






      def 					A__   (			self      :		str		)	->	List[str]:


       '''simple docstring'''

       lowercase       : Any						='''test_list = [x, add_two(x)]\ntest_list[1]'''
       lowercase       : Any						={'''x''': 3}
       lowercase       : Union[str, Any]						=evaluate(UpperCAmelCase  ,   {'''add_two''': add_two}  ,   state=UpperCAmelCase		)
       assert result == 5
       self.assertDictEqual(UpperCAmelCase  ,   {'''x''': 3, '''test_list''': [3, 5]}		)

       lowercase       : int						='''test_dict = {\'x\': x, \'y\': add_two(x)}\ntest_dict[\'y\']'''
       lowercase       : Union[str, Any]						={'''x''': 3}
       lowercase       : Tuple						=evaluate(UpperCAmelCase  ,   {'''add_two''': add_two}  ,   state=UpperCAmelCase		)
       assert result == 5
       self.assertDictEqual(UpperCAmelCase  ,   {'''x''': 3, '''test_dict''': {'''x''': 3, '''y''': 5}}		)






      def 					A__   (			self      :		List[str]		)	->	Tuple:


       '''simple docstring'''

       lowercase       : Optional[int]						='''x = 0\nfor i in range(3):\n    x = i'''
       lowercase       : List[str]						={}
       lowercase       : Union[str, Any]						=evaluate(UpperCAmelCase  ,   {'''range''': range}  ,   state=UpperCAmelCase		)
       assert result == 2
       self.assertDictEqual(UpperCAmelCase  ,   {'''x''': 2, '''i''': 2}		)



