32 lines
530 B
Python
32 lines
530 B
Python
import string
|
|
letters = string.ascii_lowercase + string.ascii_uppercase
|
|
|
|
data = []
|
|
|
|
t = 0
|
|
for line in open("input"):
|
|
data.append(line.strip())
|
|
|
|
for line in data:
|
|
n = len(line) // 2
|
|
a, b = line[:n], line[n:]
|
|
u = set(a) & set(b)
|
|
assert len(u) == 1
|
|
x = list(u)[0]
|
|
#print(x)
|
|
t += 1 + letters.index(x)
|
|
|
|
print(t)
|
|
|
|
t = 0
|
|
for i in range(0, len(data), 3):
|
|
a, b, c = map(set, data[i:i+3])
|
|
u = a & b & c
|
|
#print(u)
|
|
assert len(u) == 1
|
|
x = list(u)[0]
|
|
t += 1 + letters.index(x)
|
|
|
|
print(t)
|
|
|