30 lines
514 B
Python
30 lines
514 B
Python
|
import string
|
||
|
letters = string.ascii_lowercase + string.ascii_uppercase
|
||
|
|
||
|
rs = []
|
||
|
t = 0
|
||
|
for line in open("input"):
|
||
|
n = len(line.strip())
|
||
|
n //= 2
|
||
|
a, b = line[:n], line[n:]
|
||
|
rs.append(set(line[:2*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(rs), 3):
|
||
|
a, b, c = rs[i:i+3]
|
||
|
#print(a & b & c)
|
||
|
u = a&b&c
|
||
|
assert len(u) == 1
|
||
|
x = list(u)[0]
|
||
|
t += 1 + letters.index(x)
|
||
|
|
||
|
print(t)
|
||
|
|