Skip to content

Commit 65c3821

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 47a9932 commit 65c3821

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

searches/A_star_search.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88

99
class Cell:
10-
def __init__(self)->None:
11-
# Parent cell's row index
10+
def __init__(self) -> None:
11+
# Parent cell's row index
1212
self.parent_i = 0
1313
# Parent cell's column index
1414
self.parent_j = 0
@@ -86,7 +86,9 @@ def trace_path(cell_details: List[List[Cell]], dest: Tuple[int, int]) -> None:
8686
# Implement the A* search algorithm
8787

8888

89-
def a_star_search(grid: List[List[int]], src: Tuple[int, int], dest: Tuple[int, int]) -> None:
89+
def a_star_search(
90+
grid: List[List[int]], src: Tuple[int, int], dest: Tuple[int, int]
91+
) -> None:
9092
# Check if the source and destination are valid
9193
if not is_valid(src[0], src[1]) or not is_valid(dest[0], dest[1]):
9294
print("Source or destination is invalid")
@@ -204,8 +206,8 @@ def main() -> None:
204206
Examples:
205207
>>> main()
206208
The destination cell is found
207-
The Path is
208-
-> (8, 0) -> (7, 1) -> (6, 0) -> (5, 1) -> (4, 0) -> (3, 1) -> (2, 0) -> (1, 1) -> (0, 0)
209+
The Path is
210+
-> (8, 0) -> (7, 1) -> (6, 0) -> (5, 1) -> (4, 0) -> (3, 1) -> (2, 0) -> (1, 1) -> (0, 0)
209211
"""
210212
# Define the grid (1 for unblocked, 0 for blocked)
211213
grid = [
@@ -227,6 +229,6 @@ def main() -> None:
227229
# Run the A* search algorithm
228230
a_star_search(grid, src, dest)
229231

232+
230233
if __name__ == "__main__":
231234
main()
232-

0 commit comments

Comments
 (0)