You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
889 B
35 lines
889 B
lines = open("input.txt", 'r').read().splitlines()
|
|
|
|
letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
sum = 0
|
|
sum2 = 0
|
|
|
|
for i in range(len(lines)):
|
|
l = lines[i]
|
|
found = False
|
|
for c in l[:int(len(l)/2)]:
|
|
for d in l[int(len(l)/2):]:
|
|
if c == d:
|
|
sum += letters.index(c)+1
|
|
found = True
|
|
break
|
|
if found:
|
|
break
|
|
|
|
found = False
|
|
if i % 3 == 0:
|
|
for c in l:
|
|
for d in lines[i+1]:
|
|
if c == d:
|
|
for e in lines[i+2]:
|
|
if d == e:
|
|
sum2 += letters.index(c)+1
|
|
found = True
|
|
break
|
|
if found:
|
|
break
|
|
if found:
|
|
break
|
|
|
|
print(sum)
|
|
print(sum2) |