This commit is contained in:
Sebastian Seedorf
2023-12-06 09:30:13 +01:00
parent e40de697eb
commit 418102c1ab
3 changed files with 244 additions and 0 deletions

13
day04/part1.py Normal file
View File

@@ -0,0 +1,13 @@
#!/usr/bin/env python3
lines = (x.strip() for x in open("input.txt"))
result = 0
for line in lines:
winnings = set(int(x.strip()) for x in line[line.find(":")+1:line.find("|")].split(" ") if len(x))
you_have = set(int(x.strip()) for x in line[line.find("|")+1:].split(" ") if len(x))
num_overlap = len(you_have.intersection(winnings))
if num_overlap > 0:
result += 2**(num_overlap-1)
print(result)