


'''simple docstring'''
from heapq import heappop, heappush

import numpy as np


def 			_lowercase       (				UpperCamelCase__       :					np.ndarray,				UpperCamelCase__       :					tuple[int, int],				UpperCamelCase__       :					tuple[int, int],				UpperCamelCase__       :					bool,				):
	__A  :		Optional[Any]       =			grid.shape
	__A  :		List[Any]       =			[-1, 1, 0, 0]
	__A  :		Optional[int]       =			[0, 0, -1, 1]
	if allow_diagonal:
		dx += [-1, -1, 1, 1]
		dy += [-1, 1, -1, 1]

	__A  :		int       =			[(0, source)], set()
	__A  :		Any       =			np.full((rows, cols),				np.inf			)
	__A  :		int       =			0
	__A  :		Any       =			np.empty((rows, cols),				dtype=UpperCamelCase__			)
	__A  :		List[Any]       =			None

	while queue:
		(__A)  :		List[Any]       =			heappop(UpperCamelCase__			)
		if (x, y) in visited:
			continue
		visited.add((x, y)			)

		if (x, y) == destination:
			__A  :		Tuple       =			[]
			while (x, y) != source:
				path.append((x, y)			)
				__A  :		int       =			predecessors[x, y]
			path.append(UpperCamelCase__			)  # add the source manually
			path.reverse()
			return matrix[destination], path

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

	return np.inf, []


if __name__ == "__main__":
	import doctest

	doctest.testmod()










'''simple docstring'''
from collections.abc import Sequence


def 			_lowercase       (				UpperCamelCase__       :					Sequence[float],				UpperCamelCase__       :					float			):
 return sum(c * (x**i) for i, c in enumerate(UpperCamelCase__			)			)


def 			_lowercase       (				UpperCamelCase__       :					Sequence[float],				UpperCamelCase__       :					float			):
 __A  :		Optional[Any]       =			0.0
 for coeff in reversed(UpperCamelCase__			):
  __A  :		List[str]       =			result * x + coeff
 return result


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






