day16 - minor cleanups

This commit is contained in:
Stefan Harmuth 2024-12-16 13:37:23 +01:00
parent b296e35b85
commit 060fd324b5

View File

@ -54,7 +54,7 @@ def get_tiles_from_all_paths(grid: Grid) -> int:
visited = {} visited = {}
while queue: while queue:
score, pos, facing, path = heappop(queue) score, pos, facing, path = heappop(queue)
if pos in visited and score > visited[pos][0] + 1000: if pos in visited and score > visited[pos] + 1000:
continue continue
if pos in path_scores and pos in visited: if pos in path_scores and pos in visited:
@ -62,11 +62,7 @@ def get_tiles_from_all_paths(grid: Grid) -> int:
target_path |= path target_path |= path
continue continue
visited[pos] = (score, facing) visited[pos] = score
if pos == target:
target_path |= path
continue
if score >= target_score: if score >= target_score:
continue continue