adventofcode-2022/03/solve02.py

24 lines
473 B
Python
Raw Normal View History

2022-12-03 11:22:39 +01:00
#/usr/bin/env python
total_prio = 0
with open("input.txt", "r") as f:
i = 0
c = set()
for line in f:
line = line.strip()
i += 1
if i == 1:
c = set(line)
continue
c = c.intersection(set(line))
if i < 3:
continue
i = 0
c = ord(list(c)[0])
if c >= 97:
total_prio += c - 96
else:
total_prio += c - 38
print(total_prio)