keeping track of which symbol

This commit is contained in:
Tyrel Souza 2023-12-03 16:07:42 -05:00
parent 3c82a8a336
commit 543b0b7e82
No known key found for this signature in database
GPG Key ID: F3614B02ACBE438E

View File

@ -29,7 +29,7 @@ def part1(mat):
choose = []
nums = get_all_numbers_and_starting_coords(mat)
for coords, num in nums:
valid = process_number(mat, coords, num)
valid, symbol_coord = process_number(mat, coords, num)
if valid:
choose.append(num)
total = 0
@ -41,10 +41,10 @@ def part1(mat):
def process_number(mx, coords, num):
line_coords = get_row_coords(*coords, len(num))
for coord in line_coords:
any_symbols = [v for _,v in matrix.get_neighbor_coords(mx, *coord) if v in SYMBOLS]
any_symbols = [(cs, v) for cs,v in matrix.get_neighbor_coords(mx, *coord) if v in SYMBOLS]
if any_symbols:
return True
return False
return True, any_symbols[0]
return False, None
# @shared.profile