Skip to content

Commit

Permalink
fix: remove unneeded try..except
Browse files Browse the repository at this point in the history
Add comment for future notes
  • Loading branch information
GriceTurrble committed Dec 14, 2024
1 parent 9c5b70a commit 8766c0f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions 2024/python/src/grice_py_aoc_2024/day14/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ def simulate(self, seconds: int, grid_size: IntPair) -> IntPair:
def display_grid(positions: list[IntPair], grid_size: IntPair) -> None:
grid = [["_"] * grid_size[0] for _ in range(grid_size[1])]
for posx, posy in positions:
try:
grid[posy][posx] = "█"
except IndexError:
print(f"{posx=}, {posy=}")
raise
# Counter-intuitively, lists of lists are indexed backwards.
# The inner lists are rows, the outer list collects those rows into columns.
grid[posy][posx] = "█"
for line in grid:
print("".join(line))

Expand Down

0 comments on commit 8766c0f

Please sign in to comment.