






"""simple docstring"""



from __future__ import annotations

_UpperCamelCase		:  str						=		list[list[int]]

# assigning initial values to the grid
_UpperCamelCase		:  Matrix						=		[
    [3, 0, 6, 5, 0, 8, 4, 0, 0],
    [5, 2, 0, 0, 0, 0, 0, 0, 0],
    [0, 8, 7, 0, 0, 0, 0, 3, 1],
    [0, 0, 3, 0, 1, 0, 0, 8, 0],
    [9, 0, 0, 8, 6, 3, 0, 0, 5],
    [0, 5, 0, 0, 9, 0, 6, 0, 0],
    [1, 3, 0, 0, 0, 0, 2, 5, 0],
    [0, 0, 0, 0, 0, 0, 0, 7, 4],
    [0, 0, 5, 2, 0, 6, 3, 0, 0],
]

# a grid with no solution
_UpperCamelCase		:  Matrix						=		[
    [5, 0, 6, 5, 0, 8, 4, 0, 3],
    [5, 2, 0, 0, 0, 0, 0, 0, 2],
    [1, 8, 7, 0, 0, 0, 0, 3, 1],
    [0, 0, 3, 0, 1, 0, 0, 8, 0],
    [9, 0, 0, 8, 6, 3, 0, 0, 5],
    [0, 5, 0, 0, 9, 0, 6, 0, 0],
    [1, 3, 0, 0, 0, 0, 2, 5, 0],
    [0, 0, 0, 0, 0, 0, 0, 7, 4],
    [0, 0, 5, 2, 0, 6, 3, 0, 0],
]
def 						_SCREAMING_SNAKE_CASE (    __snake_case			:  Matrix		,					__snake_case			:  int		,					__snake_case			:  int		,					__snake_case			:  int    ):





  '''simple docstring'''





  for i in range(9    ):
    if grid[row][i] == n or grid[i][column] == n:
      return False

  for i in range(3    ):
    for j in range(3    ):
      if grid[(row - row % 3) + i][(column - column % 3) + j] == n:
        return False

  return True
def 						_SCREAMING_SNAKE_CASE (    __snake_case			:  Matrix    ):





  '''simple docstring'''





  for i in range(9    ):
    for j in range(9    ):
      if grid[i][j] == 0:
        return i, j
  return None
def 						_SCREAMING_SNAKE_CASE (    __snake_case			:  Matrix    ):





  '''simple docstring'''





  if location := find_empty_location(__snake_case    ):
    lowercase    ,     lowercase							    =       location
  else:
    # If the location is ``None``, then the grid is solved.
    return grid

  for digit in range(1		,					10    ):
    if is_safe(__snake_case		,					__snake_case		,					__snake_case		,					__snake_case    ):
      lowercase							    =       digit

      if sudoku(__snake_case    ) is not None:
        return grid

      lowercase							    =       0

  return None
def 						_SCREAMING_SNAKE_CASE (    __snake_case			:  Matrix    ):





  '''simple docstring'''





  for row in grid:
    for cell in row:
      print(__snake_case		,					end=' '    )
    print()


if __name__ == "__main__":
    # make a copy of grid so that you can compare with the unmodified grid
    for example_grid in (initial_grid, no_solution):
        print('\nExample grid:\n' + '=' * 2_0)
        print_solution(example_grid)
        print('\nExample grid solution:')
        _UpperCamelCase		:  Optional[Any]						=		sudoku(example_grid)
        if solution is not None:
            print_solution(solution)
        else:
            print('Cannot find a solution.')










"""simple docstring"""



_UpperCamelCase		:  List[str]						=		{
    'meter': 'm',
    'kilometer': 'km',
    'megametre': 'Mm',
    'gigametre': 'Gm',
    'terametre': 'Tm',
    'petametre': 'Pm',
    'exametre': 'Em',
    'zettametre': 'Zm',
    'yottametre': 'Ym',
}
# Exponent of the factor(meter)
_UpperCamelCase		:  str						=		{
    'm': 0,
    'km': 3,
    'Mm': 6,
    'Gm': 9,
    'Tm': 1_2,
    'Pm': 1_5,
    'Em': 1_8,
    'Zm': 2_1,
    'Ym': 2_4,
}
def 						_SCREAMING_SNAKE_CASE (    __snake_case			:  float		,					__snake_case			:  str		,					__snake_case			:  str    ):





  '''simple docstring'''





  lowercase							    =       from_type.lower().strip('s'    )
  lowercase							    =       to_type.lower().strip('s'    )

  lowercase							    =       UNIT_SYMBOL.get(__snake_case		,					__snake_case    )
  lowercase							    =       UNIT_SYMBOL.get(__snake_case		,					__snake_case    )

  if from_sanitized not in METRIC_CONVERSION:
    lowercase							    =       (
        f'Invalid \'from_type\' value: {from_type!r}.\n'
        f'Conversion abbreviations are: {", ".join(__snake_case    )}'
    )
    raise ValueError(__snake_case    )
  if to_sanitized not in METRIC_CONVERSION:
    lowercase							    =       (
        f'Invalid \'to_type\' value: {to_type!r}.\n'
        f'Conversion abbreviations are: {", ".join(__snake_case    )}'
    )
    raise ValueError(__snake_case    )
  lowercase							    =       METRIC_CONVERSION[from_sanitized]
  lowercase							    =       METRIC_CONVERSION[to_sanitized]
  lowercase							    =       1

  if from_exponent > to_exponent:
    lowercase							    =       from_exponent - to_exponent
  else:
    lowercase							    =       -(to_exponent - from_exponent)

  return value * pow(10		,					__snake_case    )


if __name__ == "__main__":
    from doctest import testmod

    testmod()


