keeping track of which symbol
This commit is contained in:
parent
3c82a8a336
commit
543b0b7e82
@ -29,7 +29,7 @@ def part1(mat):
|
|||||||
choose = []
|
choose = []
|
||||||
nums = get_all_numbers_and_starting_coords(mat)
|
nums = get_all_numbers_and_starting_coords(mat)
|
||||||
for coords, num in nums:
|
for coords, num in nums:
|
||||||
valid = process_number(mat, coords, num)
|
valid, symbol_coord = process_number(mat, coords, num)
|
||||||
if valid:
|
if valid:
|
||||||
choose.append(num)
|
choose.append(num)
|
||||||
total = 0
|
total = 0
|
||||||
@ -41,10 +41,10 @@ def part1(mat):
|
|||||||
def process_number(mx, coords, num):
|
def process_number(mx, coords, num):
|
||||||
line_coords = get_row_coords(*coords, len(num))
|
line_coords = get_row_coords(*coords, len(num))
|
||||||
for coord in line_coords:
|
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:
|
if any_symbols:
|
||||||
return True
|
return True, any_symbols[0]
|
||||||
return False
|
return False, None
|
||||||
|
|
||||||
|
|
||||||
# @shared.profile
|
# @shared.profile
|
||||||
|
Loading…
Reference in New Issue
Block a user