






'''simple docstring'''

from __future__ import annotations

A:      int  				=				list[list[int]]

# assigning initial values to the grid
A:      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
A:      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 	_UpperCAmelCase    (  a		:	Matrix						,			a		:	int						,			a		:	int						,			a		:	int							)			->			bool:





						"""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 	_UpperCAmelCase    (  a		:	Matrix							)			->			tuple[int, int] | None:





						"""simple docstring"""
						for i in range(9							):
												for j in range(9							):
																		if grid[i][j] == 0:
																								return i, j
						return None






def 	_UpperCAmelCase    (  a		:	Matrix							)			->			Matrix | None:





						"""simple docstring"""
						if location := find_empty_location(a							):
												lowercase_  ,      lowercase_      :   List[Any]        =			location
						else:
												# If the location is ``None``, then the grid is solved.
												return grid

						for digit in range(1						,			1_0							):
												if is_safe(a						,			a						,			a						,			a							):
																		lowercase_      :   str        =			digit

																		if sudoku(a							) is not None:
																								return grid

																		lowercase_      :   Union[str, Any]        =			0

						return None






def 	_UpperCAmelCase    (  a		:	Matrix							)			->			None:





						"""simple docstring"""
						for row in grid:
												for cell in row:
																		print(a						,			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:")
												A:      Any  				=				sudoku(example_grid)
												if solution is not None:
																		print_solution(solution)
												else:
																		print("Cannot find a solution.")








'''simple docstring'''

from __future__ import annotations






def 	_UpperCAmelCase    (  a		:	int = 4							)			->			list[list[int]]:





						"""simple docstring"""
						lowercase_      :   Tuple        =			abs(a							) or 4
						return [[1 + x + y * row_size for x in range(a							)] for y in range(a							)]






def 	_UpperCAmelCase    (  a		:	list[list[int]]							)			->			list[list[int]]:





						"""simple docstring"""
						return reverse_row(transpose(a							)							)
						# OR.. transpose(reverse_column(matrix))






def 	_UpperCAmelCase    (  a		:	list[list[int]]							)			->			list[list[int]]:





						"""simple docstring"""
						return reverse_row(reverse_column(a							)							)
						# OR.. reverse_column(reverse_row(matrix))






def 	_UpperCAmelCase    (  a		:	list[list[int]]							)			->			list[list[int]]:





						"""simple docstring"""
						return reverse_column(transpose(a							)							)
						# OR.. transpose(reverse_row(matrix))






def 	_UpperCAmelCase    (  a		:	list[list[int]]							)			->			list[list[int]]:





						"""simple docstring"""
						lowercase_      :   Any        =			[list(a							) for x in zip(*a							)]
						return matrix






def 	_UpperCAmelCase    (  a		:	list[list[int]]							)			->			list[list[int]]:





						"""simple docstring"""
						lowercase_      :   List[str]        =			matrix[::-1]
						return matrix






def 	_UpperCAmelCase    (  a		:	list[list[int]]							)			->			list[list[int]]:





						"""simple docstring"""
						lowercase_      :   str        =			[x[::-1] for x in matrix]
						return matrix






def 	_UpperCAmelCase    (  a		:	list[list[int]]							)			->			None:





						"""simple docstring"""
						for i in matrix:
												print(*a							)


if __name__ == "__main__":
						A:      Dict  				=				make_matrix()
						print("\norigin:\n")
						print_matrix(matrix)
						print("\nrotate 90 counterclockwise:\n")
						print_matrix(rotate_aa(matrix))

						A:      List[Any]  				=				make_matrix()
						print("\norigin:\n")
						print_matrix(matrix)
						print("\nrotate 180:\n")
						print_matrix(rotate_aaa(matrix))

						A:      List[str]  				=				make_matrix()
						print("\norigin:\n")
						print_matrix(matrix)
						print("\nrotate 270 counterclockwise:\n")
						print_matrix(rotate_aaa(matrix))
