


"""simple docstring"""

from heapq import heappop, heappush

import numpy as np


def lowerCAmelCase_      (				UpperCamelCase__	: np.ndarray				,   UpperCamelCase__	: tuple[int, int]				,   UpperCamelCase__	: tuple[int, int]				,   UpperCamelCase__	: bool				,   ):






 """simple docstring"""







 __lowercase									=	grid.shape
 __lowercase									=	[-1, 1, 0, 0]
 __lowercase									=	[0, 0, -1, 1]
 if allow_diagonal:
  dx += [-1, -1, 1, 1]
  dy += [-1, 1, -1, 1]

 __lowercase									=	[(0, source)], set()
 __lowercase									=	np.full((rows, cols)				,   np.inf )
 __lowercase									=	0
 __lowercase									=	np.empty((rows, cols)				,   dtype=lowerCAmelCase__ )
 __lowercase									=	None

 while queue:
  (__lowercase)									=	heappop(lowerCAmelCase__ )
  if (x, y) in visited:
   continue
  visited.add((x, y) )

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

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

 return np.inf, []


if __name__ == "__main__":
       import doctest

       doctest.testmod()




"""simple docstring"""

from collections.abc import Callable

import numpy as np


def lowerCAmelCase_      (				UpperCamelCase__	: Callable				,   UpperCamelCase__	: float				,   UpperCamelCase__	: float				,   UpperCamelCase__	: float				,   UpperCamelCase__	: float ):






 """simple docstring"""







 __lowercase									=	int(np.ceil((x_end - xa) / step_size ) )
 __lowercase									=	np.zeros((n + 1,) )
 __lowercase									=	ya
 __lowercase									=	xa

 for k in range(UpperCamelCase__ ):
  __lowercase									=	y[k] + step_size * ode_func(UpperCamelCase__				,   y[k] )
  x += step_size

 return y


if __name__ == "__main__":
       import doctest

       doctest.testmod()
