1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
with open("input", "r") as f:
l = f.read().split('\n')[:-1]
x = []
total = 0
for line in l:
n = len(line)
x.append([line[:int(n/2)], line[int(n/2):]])
for line in x:
for char in line[1]:
if char in line[0]:
total += "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".index(char) + 1
break
print(total)
total = 0
for i in range(0, len(l), 3):
common = set(l[i]) & set(l[i+1]) & set(l[i+2])
if (len(common) != 1):
print("ERROR", common)
total += "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".index(list(common)[0]) + 1
i += 3
print(total)
|