1
1
# Knight Tour Intro: https://www.youtube.com/watch?v=ab_dY3dZFHM
2
2
3
- from typing import List , Tuple
3
+ from __future__ import annotations
4
4
5
5
6
- def get_valid_pos (position : Tuple [int ], n : int ) -> List [ Tuple [int ]]:
6
+ def get_valid_pos (position : tuple [int ], n : int ) -> list [ tuple [int ]]:
7
7
"""
8
8
Find all the valid positions a knight can move to from the current position.
9
9
@@ -32,7 +32,7 @@ def get_valid_pos(position: Tuple[int], n: int) -> List[Tuple[int]]:
32
32
return permissible_positions
33
33
34
34
35
- def is_complete (board : List [ List [int ]]) -> bool :
35
+ def is_complete (board : list [ list [int ]]) -> bool :
36
36
"""
37
37
Check if the board (matrix) has been completely filled with non-zero values.
38
38
@@ -46,7 +46,7 @@ def is_complete(board: List[List[int]]) -> bool:
46
46
return not any (elem == 0 for row in board for elem in row )
47
47
48
48
49
- def open_knight_tour_helper (board : List [ List [int ]], pos : Tuple [int ], curr : int ) -> bool :
49
+ def open_knight_tour_helper (board : list [ list [int ]], pos : tuple [int ], curr : int ) -> bool :
50
50
"""
51
51
Helper function to solve knight tour problem.
52
52
"""
@@ -66,7 +66,7 @@ def open_knight_tour_helper(board: List[List[int]], pos: Tuple[int], curr: int)
66
66
return False
67
67
68
68
69
- def open_knight_tour (n : int ) -> List [ List [int ]]:
69
+ def open_knight_tour (n : int ) -> list [ list [int ]]:
70
70
"""
71
71
Find the solution for the knight tour problem for a board of size n. Raises
72
72
ValueError if the tour cannot be performed for the given size.
0 commit comments