sort sensors by iteration axis

This commit is contained in:
Luke Hubmayer-Werner 2022-12-16 00:57:21 +10:30
parent b79dbd3291
commit 9c01ca2bcd
1 changed files with 1 additions and 2 deletions

View File

@ -46,11 +46,10 @@ def do_sensors_2(lines: list[str], search_space: int):
continue continue
distance = abs(x-nx) + abs(y-ny) distance = abs(x-nx) + abs(y-ny)
sensors.append((x, y, distance)) sensors.append((x, y, distance))
sensors.sort(key=lambda x: x[0])
# print(sensors) # print(sensors)
for x in range(0, search_space+1): for x in range(0, search_space+1):
# if x % 100_000 == 0:
# print(f'Processed {x} rows')
y = 0 y = 0
while y <= search_space: while y <= search_space:
y_skip = in_range_of_sensors(sensors, x, y) y_skip = in_range_of_sensors(sensors, x, y)