mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 01:09:40 +08:00
Pyupgrade to Python 3.9 (#4718)
* Pyupgrade to Python 3.9 * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
@ -9,9 +9,9 @@ function on the next column to see if it returns True. if yes, we
|
||||
have solved the puzzle. else, we backtrack and place another number
|
||||
in that cell and repeat this process.
|
||||
"""
|
||||
from typing import List, Optional, Tuple
|
||||
from __future__ import annotations
|
||||
|
||||
Matrix = List[List[int]]
|
||||
Matrix = list[list[int]]
|
||||
|
||||
# assigning initial values to the grid
|
||||
initial_grid: Matrix = [
|
||||
@ -59,7 +59,7 @@ def is_safe(grid: Matrix, row: int, column: int, n: int) -> bool:
|
||||
return True
|
||||
|
||||
|
||||
def find_empty_location(grid: Matrix) -> Optional[Tuple[int, int]]:
|
||||
def find_empty_location(grid: Matrix) -> tuple[int, int] | None:
|
||||
"""
|
||||
This function finds an empty location so that we can assign a number
|
||||
for that particular row and column.
|
||||
@ -71,7 +71,7 @@ def find_empty_location(grid: Matrix) -> Optional[Tuple[int, int]]:
|
||||
return None
|
||||
|
||||
|
||||
def sudoku(grid: Matrix) -> Optional[Matrix]:
|
||||
def sudoku(grid: Matrix) -> Matrix | None:
|
||||
"""
|
||||
Takes a partially filled-in grid and attempts to assign values to
|
||||
all unassigned locations in such a way to meet the requirements
|
||||
|
Reference in New Issue
Block a user