Files
aoc-2022/3/onestar.py
T
Mark Hoekveen 262ebfc619 first 13 stars
2024-09-24 11:59:44 +02:00

25 lines
577 B
Python

def priority(item):
if item < 'a':
# uppercase
return ord(item)-38
else:
# lowercase
return ord(item)-96
priorities = []
with open("input.txt", "r") as f:
for line in f.readlines():
line = line.strip("\n")
#print(line)
h = int(len(line)/2)
left = line[:h]
right = line[h:]
print(left, end=" | ")
print(right)
for c in left:
if c in right:
priorities.append(priority(c))
print(c)
break
print(sum(priorities))