-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathd4p1.py
More file actions
30 lines (28 loc) · 700 Bytes
/
d4p1.py
File metadata and controls
30 lines (28 loc) · 700 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
def main():
total = 0
with open("input4.txt", "r") as input:
for line in input:
total += check(line)
print(total)
def check(line):
temp = 0
s = line[8:]
winning, check = s.split("|")
winlist = []
checklist = []
for a in winning.split(" "):
winlist.append(a.strip())
for a in check.split(" "):
checklist.append(a.strip())
for to_check in checklist:
try:
if int(to_check) and to_check in winlist:
if temp == 0:
temp = 1
else:
temp *= 2
except:
continue
return temp
if __name__ == "__main__":
main()