q2 : easy
This commit is contained in:
parent
fe493d647d
commit
eac8ccf339
1 changed files with 12 additions and 2 deletions
|
@ -17,11 +17,21 @@ def part1(file: str):
|
||||||
|
|
||||||
|
|
||||||
def part2(file: str):
|
def part2(file: str):
|
||||||
|
array = []
|
||||||
with open(file) as f:
|
with open(file) as f:
|
||||||
for line in 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__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in a new issue