day 3 slight simplification
parent
46ba7f1593
commit
6c0f46fd2b
15
day03/sol.py
15
day03/sol.py
|
@ -44,12 +44,11 @@ for no, line in enumerate(data):
|
||||||
print(n)
|
print(n)
|
||||||
part1 += n
|
part1 += n
|
||||||
|
|
||||||
seen = set()
|
nearby_gears = set()
|
||||||
for i in pos:
|
for i in pos:
|
||||||
for g in findgears(no,i):
|
nearby_gears.update(findgears(no, i))
|
||||||
if g not in seen:
|
for g in nearby_gears:
|
||||||
gears.setdefault(g, []).append(n)
|
gears.setdefault(g, []).append(n)
|
||||||
seen.add(g)
|
|
||||||
|
|
||||||
print(part1)
|
print(part1)
|
||||||
|
|
||||||
|
@ -58,11 +57,3 @@ for g, nums in gears.items():
|
||||||
if len(nums) == 2:
|
if len(nums) == 2:
|
||||||
part2 += nums[0] * nums[1]
|
part2 += nums[0] * nums[1]
|
||||||
print(part2)
|
print(part2)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue