





from math import atan, cos, radians, sin, tan

from .haversine_distance import haversine_distance

_UpperCAmelCase             =							6_378_137.0
_UpperCAmelCase             =							6_356_752.314_245
_UpperCAmelCase             =							637_8137






def 	_SCREAMING_SNAKE_CASE		(      SCREAMING_SNAKE_CASE		:float   ,   SCREAMING_SNAKE_CASE		:float   ,   SCREAMING_SNAKE_CASE		:float   ,   SCREAMING_SNAKE_CASE		:float   )      ->   float:
 __lowerCAmelCase					:	Dict      =       (AXIS_A - AXIS_B) / AXIS_A
 # Parametric latitudes
 # https://en.wikipedia.org/wiki/Latitude#Parametric_(or_reduced)_latitude
 __lowerCAmelCase					:	Tuple      =       atan((1 - flattening) * tan(radians(SCREAMING_SNAKE_CASE   )   )   )
 __lowerCAmelCase					:	Optional[Any]      =       atan((1 - flattening) * tan(radians(SCREAMING_SNAKE_CASE   )   )   )

 # Compute central angle between two points
 # using haversine theta. sigma =  haversine_distance / equatorial radius
 __lowerCAmelCase					:	Dict      =       haversine_distance(SCREAMING_SNAKE_CASE   ,   SCREAMING_SNAKE_CASE   ,   SCREAMING_SNAKE_CASE   ,   SCREAMING_SNAKE_CASE   ) / EQUATORIAL_RADIUS

 # Intermediate P and Q values
 __lowerCAmelCase					:	List[Any]      =       (b_lata + b_lata) / 2
 __lowerCAmelCase					:	List[Any]      =       (b_lata - b_lata) / 2

 # Intermediate X value
 # X = (sigma - sin(sigma)) * sin^2Pcos^2Q / cos^2(sigma/2)
 __lowerCAmelCase					:	List[str]      =       (sin(SCREAMING_SNAKE_CASE   ) ** 2) * (cos(SCREAMING_SNAKE_CASE   ) ** 2)
 __lowerCAmelCase					:	Optional[int]      =       cos(sigma / 2   ) ** 2
 __lowerCAmelCase					:	Tuple      =       (sigma - sin(SCREAMING_SNAKE_CASE   )) * (x_numerator / x_demonimator)

 # Intermediate Y value
 # Y = (sigma + sin(sigma)) * cos^2Psin^2Q / sin^2(sigma/2)
 __lowerCAmelCase					:	Tuple      =       (cos(SCREAMING_SNAKE_CASE   ) ** 2) * (sin(SCREAMING_SNAKE_CASE   ) ** 2)
 __lowerCAmelCase					:	Tuple      =       sin(sigma / 2   ) ** 2
 __lowerCAmelCase					:	Any      =       (sigma + sin(SCREAMING_SNAKE_CASE   )) * (y_numerator / y_denominator)

 return EQUATORIAL_RADIUS * (sigma - ((flattening / 2) * (x_value + y_value)))


if __name__ == "__main__":
      import doctest

      doctest.testmod()






from __future__ import annotations






def 	_SCREAMING_SNAKE_CASE		(      SCREAMING_SNAKE_CASE		:list[list[int]]   )      ->   bool:
 __lowerCAmelCase					:	Tuple      =       len(SCREAMING_SNAKE_CASE   )
 # We need to create solution object to save path.
 __lowerCAmelCase					:	str      =       [[0 for _ in range(SCREAMING_SNAKE_CASE   )] for _ in range(SCREAMING_SNAKE_CASE   )]
 __lowerCAmelCase					:	str      =       run_maze(SCREAMING_SNAKE_CASE   ,   0   ,   0   ,   SCREAMING_SNAKE_CASE   )
 if solved:
  print("""\n""".join(str(SCREAMING_SNAKE_CASE   ) for row in solutions   )   )
 else:
  print("""No solution exists!"""   )
 return solved






def 	_SCREAMING_SNAKE_CASE		(      SCREAMING_SNAKE_CASE		:list[list[int]]   ,   SCREAMING_SNAKE_CASE		:int   ,   SCREAMING_SNAKE_CASE		:int   ,   SCREAMING_SNAKE_CASE		:list[list[int]]   )      ->   bool:
 __lowerCAmelCase					:	List[str]      =       len(SCREAMING_SNAKE_CASE   )
 # Final check point.
 if i == j == (size - 1):
  __lowerCAmelCase					:	str      =       1
  return True

 __lowerCAmelCase					:	Optional[Any]      =       (not i < 0) and (not j < 0)  # Check lower bounds
 __lowerCAmelCase					:	Optional[Any]      =       (i < size) and (j < size)  # Check upper bounds

 if lower_flag and upper_flag:
  # check for already visited and block points.
  __lowerCAmelCase					:	int      =       (not solutions[i][j]) and (not maze[i][j])
  if block_flag:
   # check visited
   __lowerCAmelCase					:	Tuple      =       1

   # check for directions
   if (
       run_maze(SCREAMING_SNAKE_CASE   ,   i + 1   ,   SCREAMING_SNAKE_CASE   ,   SCREAMING_SNAKE_CASE   )
       or run_maze(SCREAMING_SNAKE_CASE   ,   SCREAMING_SNAKE_CASE   ,   j + 1   ,   SCREAMING_SNAKE_CASE   )
       or run_maze(SCREAMING_SNAKE_CASE   ,   i - 1   ,   SCREAMING_SNAKE_CASE   ,   SCREAMING_SNAKE_CASE   )
       or run_maze(SCREAMING_SNAKE_CASE   ,   SCREAMING_SNAKE_CASE   ,   j - 1   ,   SCREAMING_SNAKE_CASE   )
   ):
    return True

   __lowerCAmelCase					:	Tuple      =       0
   return False
 return False


if __name__ == "__main__":
      import doctest

      doctest.testmod()