from heapq import heappop, heappush

import numpy as np




def       _snake_case	(   lowerCAmelCase							:   Tuple   , lowerCAmelCase							:   Dict   , lowerCAmelCase							:   Optional[int]   , lowerCAmelCase							:   str   , ):
		"""simple docstring"""







		SCREAMING_SNAKE_CASE_  :		Union[str, Any]				      =    grid.shape
		SCREAMING_SNAKE_CASE_  :		List[str]				      =    [-1, 1, 0, 0]
		SCREAMING_SNAKE_CASE_  :		Dict				      =    [0, 0, -1, 1]
		if allow_diagonal:
				dx += [-1, -1, 1, 1]
				dy += [-1, 1, -1, 1]

		SCREAMING_SNAKE_CASE_  :		Any				      =    [(0, source)], set()
		SCREAMING_SNAKE_CASE_  :		Tuple				      =    np.full((rows, cols)   , np.inf	)
		SCREAMING_SNAKE_CASE_  :		List[str]				      =    0
		SCREAMING_SNAKE_CASE_  :		Optional[int]				      =    np.empty((rows, cols)   , dtype=lowerCAmelCase	)
		SCREAMING_SNAKE_CASE_  :		str				      =    None

		while queue:
				(SCREAMING_SNAKE_CASE_)  :		List[str]				      =    heappop(lowerCAmelCase	)
				if (x, y) in visited:
						continue
				visited.add((x, y)	)

				if (x, y) == destination:
						SCREAMING_SNAKE_CASE_  :		Optional[int]				      =    []
						while (x, y) != source:
								path.append((x, y)	)
								SCREAMING_SNAKE_CASE_  :		List[Any]				      =    predecessors[x, y]
						path.append(lowerCAmelCase	)  # add the source manually
						path.reverse()
						return matrix[destination], path

				for i in range(len(lowerCAmelCase	)	):
						SCREAMING_SNAKE_CASE_  :		Union[str, Any]				      =    x + dx[i], y + dy[i]
						if 0 <= nx < rows and 0 <= ny < cols:
								SCREAMING_SNAKE_CASE_  :		Any				      =    grid[nx][ny]
								if next_node == 1 and matrix[nx, ny] > dist + 1:
										heappush(lowerCAmelCase   , (dist + 1, (nx, ny))	)
										SCREAMING_SNAKE_CASE_  :		Union[str, Any]				      =    dist + 1
										SCREAMING_SNAKE_CASE_  :		List[str]				      =    (x, y)

		return np.inf, []


if __name__ == "__main__":
		import doctest

		doctest.testmod()








'''simple docstring'''







from collections.abc import Sequence





def  SCREAMING_SNAKE_CASE_       (UpperCamelCase				,			UpperCamelCase      )      ->       float:
							return sum(c * (x**i) for i, c in enumerate(UpperCamelCase      )      )





def  SCREAMING_SNAKE_CASE_       (UpperCamelCase				,			UpperCamelCase      )      ->       float:
							lowerCamelCase__					:	str         =       0.0
							for coeff in reversed(UpperCamelCase      ):
														lowerCamelCase__					:	Optional[int]         =       result * x + coeff
							return result


if __name__ == "__main__":
			_A	:			Any         =(0.0, 0.0, 5.0, 9.3, 7.0)
			_A	:			Optional[Any]         =10.0
			print(evaluate_poly(poly, x))
			print(horner(poly, x))

