Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Stegallo committed Dec 8, 2024
1 parent 7e14715 commit c22906e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions y_2024/day6.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,20 @@ def _calculate_1(self) -> int:
return sum(1 for i in grid.values() if i == "X")

def _calculate_2(self) -> int:
result = 0
for i in self._visited_in_1 - {self.starting_point}:
result += self.run_in_circle(self.grid, i)
return result
return sum(
self.run_in_circle(self.grid, i)
for i in self._visited_in_1 - {self.starting_point}
)

def run_in_circle(self, grid, i: Point) -> bool:
grid = dict(grid.items())
grid[i] = "#"

curs = Cursor(
self.starting_point,
Direction.from_symbol(grid[self.starting_point]),
)
grid[i] = "#"

visited = {}
while True:
visited[(curs.pos, curs.dir)] = True
Expand Down

0 comments on commit c22906e

Please sign in to comment.