'''simple docstring'''

from collections.abc import Callable
from math import pi, sqrt
from random import uniform
from statistics import mean



def snake_case_      (					__snake_case  :							int)			->					Union[str, Any]:

   # A local function to see if a dot lands in the circle.
   def is_in_circle(__snake_case  :							float	,   __snake_case  :							float) -> bool:
      lowerCAmelCase_			=      sqrt((x**2) + (y**2))
      # Our circle has a radius of 1, so a distance
      # greater than 1 would land outside the circle.
      return distance_from_centre <= 1

   # The proportion of guesses that landed in the circle
   lowerCAmelCase_			=      mean(
       int(is_in_circle(uniform(-1.0	,   1.0)	,   uniform(-1.0	,   1.0)))
       for _ in range(__snake_case))
   # The ratio of the area for circle to square is pi/4.
   lowerCAmelCase_			=      proportion * 4
   print(F'''The estimated value of pi is {pi_estimate}''')
   print(F'''The numpy value of pi is {pi}''')
   print(F'''The total error is {abs(pi - pi_estimate)}''')



def snake_case_      (					__snake_case  :							int	,   __snake_case  :							Callable[[float], float]	,   __snake_case  :							float = 0.0	,   __snake_case  :							float = 1.0	,   )			->					float:
   return mean(
       function_to_integrate(uniform(__snake_case	,   __snake_case)) for _ in range(__snake_case)) * (max_value - min_value)



def snake_case_      (					__snake_case  :							int	,   __snake_case  :							float = 0.0	,   __snake_case  :							float = 1.0)			->					None:

   def identity_function(__snake_case  :							float) -> float:
      return x

   lowerCAmelCase_			=      area_under_curve_estimator(
       __snake_case	,   __snake_case	,   __snake_case	,   __snake_case)
   lowerCAmelCase_			=      (max_value * max_value - min_value * min_value) / 2

   print('''******************''')
   print(F'''Estimating area under y=x where x varies from {min_value} to {max_value}''')
   print(F'''Estimated value is {estimated_value}''')
   print(F'''Expected value is {expected_value}''')
   print(F'''Total error is {abs(estimated_value - expected_value)}''')
   print('''******************''')



def snake_case_      (					__snake_case  :							int)			->					None:

   def function_to_integrate(__snake_case  :							float) -> float:
      return sqrt(4.0 - x * x)

   lowerCAmelCase_			=      area_under_curve_estimator(
       __snake_case	,   __snake_case	,   0.0	,   2.0)

   print('''******************''')
   print('''Estimating pi using area_under_curve_estimator''')
   print(F'''Estimated value is {estimated_value}''')
   print(F'''Expected value is {pi}''')
   print(F'''Total error is {abs(estimated_value - pi)}''')
   print('''******************''')


if __name__ == "__main__":
 import doctest

 doctest.testmod()






'''simple docstring'''

import os



def snake_case_      (					__snake_case  :							List[Any])			->					str:
   lowerCAmelCase_			=      len(grid[0])
   lowerCAmelCase_			=      len(__snake_case)

   lowerCAmelCase_			=      0
   lowerCAmelCase_			=      0
   lowerCAmelCase_			=      0

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

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

   return largest



def snake_case_      (					)			->					List[Any]:
   lowerCAmelCase_			=      []
   with open(os.path.dirname(__snake_case) + '''/grid.txt''') as file:
      for line in file:
         grid.append(line.strip('''\n''').split(''' '''))

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

   return largest_product(__snake_case)


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





