adventofcode-2022/03/solve01.py
Peter Hudec da38a63b74 day03
2022-12-03 11:22:39 +01:00

18 lines
392 B
Python

#/usr/bin/env python
total_prio = 0
with open("input.txt", "r") as f:
for line in f:
l2 = int(len(line.strip())/2)
c1 = set(line[:l2])
c2 = set(line[l2:])
c = c1.intersection(c2)
c = ord(list(c)[0])
if c >= 97:
total_prio += c - 96
else:
total_prio += c - 38
print(total_prio)