We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c2869c6 commit 73a672bCopy full SHA for 73a672b
src/bfs.py
@@ -45,16 +45,15 @@ def bfs(win, startEnd, walls):
45
q.append((start_x + row[k], start_y + col[k], dist + 1, add + move[k]))
46
win.write('@', end_x, end_y)
47
48
- # find path
49
- start_x, start_y = startEnd[0]
50
- for i in range(len(add)):
51
- index = move.index(add[i])
52
- start_x, start_y = start_x + row[index], start_y + col[index]
53
- win.write('+', start_x, start_y, fgcolor='red')
54
- time.sleep(0.02)
55
- win.write('@', end_x, end_y)
56
-
57
if min_dist != sys.maxsize:
+ # find path
+ start_x, start_y = startEnd[0]
+ for i in range(len(add)):
+ index = move.index(add[i])
+ start_x, start_y = start_x + row[index], start_y + col[index]
+ win.write('+', start_x, start_y, fgcolor='red')
+ time.sleep(0.02)
+ win.write('@', end_x, end_y)
58
win.write(f"The shortest path from source to destination has length {min_dist}", 1, 1)
59
else:
60
win.write("Destination can't be reached from a given source", 1, 1)
0 commit comments