Skip to content

Commit 9ede475

Browse files
committed
[2024/6] add comments to simulate()
1 parent 637f02d commit 9ede475

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

2024/6/script.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,16 @@ def simulate(pos: tuple, dir_: Dir, grid: Grid) -> tuple[set, list, bool]:
2727
while grid.in_bounds(pos):
2828
pos, dir_ = move(pos, dir_, grid)
2929
visited.add(pos)
30+
# we changed direction
3031
if path[-1][0] == pos:
3132
path.append((pos, dir_))
3233
path.append((pos, None))
3334
path_set.add((pos, dir_))
35+
# we're following a previous path, loop found
3436
elif (pos, dir_) in path_set:
3537
loops = True
3638
break
39+
# we just moved forward
3740
else:
3841
path.append((pos, dir_))
3942
path_set.add((pos, dir_))

0 commit comments

Comments
 (0)