Move into 2022 folder

This commit is contained in:
Mark Hoekveen
2024-11-11 09:05:01 +01:00
parent 9dd6a4f275
commit e0d955ec6f
28 changed files with 5 additions and 11 deletions
+22
View File
@@ -0,0 +1,22 @@
def priority(item):
if item < 'a':
# uppercase
return ord(item)-38
else:
# lowercase
return ord(item)-96
priorities = []
groups = []
with open("input.txt", "r") as f:
group = 0
for line in f.readlines():
line = line.strip("\n")
groups.append(line)
if len(groups) == 3:
for c in groups[0]:
if c in groups[1] and c in groups[2]:
priorities.append(priority(c))
groups = []
break
print(sum(priorities))