adventOfCode/2023/4/part2.py
2023-12-04 17:57:11 +01:00

14 lines
No EOL
446 B
Python

copymap = [0] * 204
for num, line in enumerate(open("./input2")):
matchingNums = len(([
number for number in
((set(x.strip() for x in (line.split("|")[0].split(":")[1].split(" "))))
& set(x.strip() for x in (line.split("|")[1].split(" "))))
if number != ""
]))
toAdd = copymap[num] + 1
for i in range(1, matchingNums + 1):
copymap[num + i] += toAdd
print(sum(copymap) + num + 1) # 6857330