mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 17:34:49 +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:
@ -1,9 +1,9 @@
|
||||
# Knight Tour Intro: https://www.youtube.com/watch?v=ab_dY3dZFHM
|
||||
|
||||
from typing import List, Tuple
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
def get_valid_pos(position: Tuple[int, int], n: int) -> List[Tuple[int, int]]:
|
||||
def get_valid_pos(position: tuple[int, int], n: int) -> list[tuple[int, int]]:
|
||||
"""
|
||||
Find all the valid positions a knight can move to from the current position.
|
||||
|
||||
@ -32,7 +32,7 @@ def get_valid_pos(position: Tuple[int, int], n: int) -> List[Tuple[int, int]]:
|
||||
return permissible_positions
|
||||
|
||||
|
||||
def is_complete(board: List[List[int]]) -> bool:
|
||||
def is_complete(board: list[list[int]]) -> bool:
|
||||
"""
|
||||
Check if the board (matrix) has been completely filled with non-zero values.
|
||||
|
||||
@ -47,7 +47,7 @@ def is_complete(board: List[List[int]]) -> bool:
|
||||
|
||||
|
||||
def open_knight_tour_helper(
|
||||
board: List[List[int]], pos: Tuple[int, int], curr: int
|
||||
board: list[list[int]], pos: tuple[int, int], curr: int
|
||||
) -> bool:
|
||||
"""
|
||||
Helper function to solve knight tour problem.
|
||||
@ -68,7 +68,7 @@ def open_knight_tour_helper(
|
||||
return False
|
||||
|
||||
|
||||
def open_knight_tour(n: int) -> List[List[int]]:
|
||||
def open_knight_tour(n: int) -> list[list[int]]:
|
||||
"""
|
||||
Find the solution for the knight tour problem for a board of size n. Raises
|
||||
ValueError if the tour cannot be performed for the given size.
|
||||
|
Reference in New Issue
Block a user