q2 : easy

This commit is contained in:
Mylloon 2023-12-04 16:15:17 +01:00
parent fe493d647d
commit eac8ccf339
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -17,11 +17,21 @@ def part1(file: str):
def part2(file: str):
array = []
with open(file) as f:
for line in f:
pass
tmp = []
for el in [i.split(" ") for i in line.split(":")[1].split("|")]:
tmp.append([int(it) for it in el if len(it) > 0])
array.append(tmp)
return 0
sets = [1 for _ in array]
for num_set, card in enumerate(array):
num_matches = len(set(card[0]) & set(card[1]))
for j in range(num_matches):
sets[num_set + 1 + j] += sets[num_set]
return sum(sets)
if __name__ == "__main__":