22 lines
492 B
Python
22 lines
492 B
Python
|
#!/usr/bin/env python
|
||
|
# 2022 - Advent Of Code 3
|
||
|
|
||
|
#file = 'input_example.txt'
|
||
|
file = 'input.txt'
|
||
|
|
||
|
prio = 0
|
||
|
|
||
|
with open(file, encoding="utf-8") as f:
|
||
|
for line in f.readlines():
|
||
|
half_len = int(len(line.strip()) / 2)
|
||
|
str1 = line[:half_len]
|
||
|
str2 = line[half_len:]
|
||
|
common = list(set(str1).intersection(str2))
|
||
|
num = ord(common[0])
|
||
|
if num > 90: # lower case
|
||
|
prio += num - 96
|
||
|
else:
|
||
|
prio += num - 64 + 26
|
||
|
|
||
|
print(prio)
|