






'''simple docstring'''

from heapq import heappop, heappush

import numpy as np







def 					lowercase__				(   __UpperCamelCase	,		__UpperCamelCase	,		__UpperCamelCase	,		__UpperCamelCase	,		)->				tuple[float | int, list[tuple[int, int]]]:
      UpperCamelCase						,UpperCamelCase       						=      grid.shape
      UpperCamelCase       						=      [-1, 1, 0, 0]
      UpperCamelCase       						=      [0, 0, -1, 1]
      if allow_diagonal:
            dx += [-1, -1, 1, 1]
            dy += [-1, 1, -1, 1]

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

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

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

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

      return np.inf, []


if __name__ == "__main__":
     import doctest

     doctest.testmod()








'''simple docstring'''

from __future__ import annotations







def 					lowercase__				(   __UpperCamelCase	,		__UpperCamelCase	,		__UpperCamelCase					)->				dict[str, float]:
      if (voltage, current, resistance).count(0					) != 1:
            raise ValueError("""One and only one argument must be 0"""					)
      if resistance < 0:
            raise ValueError("""Resistance cannot be negative"""					)
      if voltage == 0:
            return {"voltage": float(current * resistance					)}
      elif current == 0:
            return {"current": voltage / resistance}
      elif resistance == 0:
            return {"resistance": voltage / current}
      else:
            raise ValueError("""Exactly one argument must be 0"""					)


if __name__ == "__main__":
     import doctest

     doctest.testmod()
