Moved mutable class attributes as per concern from repository test merge

This commit is contained in:
miltonbhowmick 2023-08-08 11:51:06 +06:00
parent 60a8d009eb
commit 85d33bea6c

View File

@ -1,11 +1,5 @@
import heapq
class UniformCostSearch:
def __init__(self, grid: list[list[int]]) -> None:
self.m = len(grid[0])
self.n = len(grid)
# diagonal clockwise
dxy1 = [
(1, 1),
@ -74,6 +68,12 @@ class UniformCostSearch:
(-1, 1),
]
class UniformCostSearch:
def __init__(self, grid: list[list[int]]) -> None:
self.m = len(grid[0])
self.n = len(grid)
def get_shortest_path(
self,
start: list[int],
@ -192,17 +192,17 @@ class UniformCostSearch:
prev = [[None for _ in range(self.m)] for _ in range(self.n)]
dxy = []
if start_point[1] - end_point[1] == 0 and start_point[0] - end_point[0] < 0:
dxy = self.dxy5
dxy = dxy5
elif start_point[1] - end_point[1] == 0 and start_point[0] - end_point[0] > 0:
dxy = self.dxy6
dxy = dxy6
elif start_point[0] - end_point[0] == 0 and start_point[1] - end_point[1] < 0:
dxy = self.dxy4
dxy = dxy4
elif start_point[0] - end_point[0] == 0 and start_point[1] - end_point[1] > 0:
dxy = self.dxy3
dxy = dxy3
elif start_point[0] - end_point[0] > 0:
dxy = self.dxy2
dxy = dxy2
elif start_point[0] - end_point[0] < 0:
dxy = self.dxy1
dxy = dxy1
goal_answer = []
for _ in range(0, len(end_point)):
goal_answer.append(10**8)