Skip to content

Commit

Permalink
switched visited to a dict
Browse files Browse the repository at this point in the history
  • Loading branch information
mooja committed Aug 20, 2017
1 parent 97bca7c commit e698acc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions challenge325easy.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
y = len(maze)-1
que.append((x, y, 0, ''))

visited = []
visited = {}
while que:
x, y, color_seq_idx, history = que.pop()
if y == 0:
Expand All @@ -64,7 +64,7 @@
next_color_seq = (color_seq_idx + 1) % len(color_seq)
next_color = color_seq[next_color_seq]

if (_x, _y, next_color_seq) in visited:
if (_x, _y, next_color_seq) in visited.keys():
continue

try:
Expand All @@ -74,4 +74,4 @@
except IndexError:
continue

visited.append((x, y, color_seq_idx))
visited[(x, y, color_seq_idx)] = True

0 comments on commit e698acc

Please sign in to comment.