Skip to content

Commit

Permalink
Simplify search for symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
fuglede committed Dec 3, 2023
1 parent 4d3287d commit 301ac48
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions 2023/day03/solutions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
ls = f.read().strip().split("\n")

box = list(itertools.product((-1, 0, 1), (-1, 0, 1)))
board = {(i, j): ls[i][j] for i in range(len(ls)) for j in range(len(ls[0]))}
symbols = {x for x in board if board[x] != "." and not board[x].isdigit()}
symbols = {
(i, j)
for i, l in enumerate(ls)
for j, x in enumerate(l)
if x != "." and not x.isdigit()
}

part_sum = 0
parts_by_symbol = defaultdict(list)
Expand Down

0 comments on commit 301ac48

Please sign in to comment.