2022 day 3

This commit is contained in:
2022-12-03 09:10:39 +00:00
parent 3ccc8b3ebf
commit 4678f22963
3 changed files with 351 additions and 0 deletions

25
2022/03/part1 Executable file
View File

@@ -0,0 +1,25 @@
#!/usr/bin/env python
VALS = {}
for i in range(ord('a'), ord('z')+1):
VALS[chr(i)] = i - ord('a') + 1
for i in range(ord('A'), ord('Z')+1):
VALS[chr(i)] = i - ord('A') + 27
score = 0
with open('input') as f:
for line in f:
line = line.rstrip()
half = len(line)//2
compA = line[0:half]
compB = line[half:len(line)]
common = set(compA) & set(compB)
score = score + VALS[common.pop()]
print(score)