parent
860884e5b2
commit
681a186337
1 changed files with 12 additions and 0 deletions
@ -0,0 +1,12 @@ |
||||
lines = [(int(m[0][-1]), [[int(o) for o in n.split(" ") if o!= ""] for n in m[1].split(" | ")]) for m in [l.split(": ") for l in open("input.txt", "r").read().splitlines()]] |
||||
|
||||
summa = 0 |
||||
|
||||
for l in lines: |
||||
hits = len(set(l[1][0]).intersection(l[1][1])) |
||||
summa += pow(2, hits-1) if hits > 0 else 0 |
||||
|
||||
print(summa) |
||||
|
||||
#cursed one line solution to part 1 |
||||
#print(sum([int(pow(2, len(set(l[1][0]).intersection(l[1][1]))-1)) for l in [(int(m[0][-1]), [[int(o) for o in n.split(" ") if o!= ""] for n in m[1].split(" | ")]) for m in [l.split(": ") for l in open("input.txt", "r").read().splitlines()]]])) |
Loading…
Reference in new issue