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
902 B

12 months ago
lines = [i for i in open("input.txt", 'r').read().splitlines()]
letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
sum = 0
12 months ago
sum2 = 0
12 months ago
12 months ago
for i in range(len(lines)):
l = lines[i]
12 months ago
found = False
for c in l[:int(len(l)/2)]:
for d in l[int(len(l)/2):]:
if c == d:
12 months ago
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)