adventofcode/2022/03/01.py
2022-12-03 15:36:56 +01:00

23 lines
529 B
Python
Executable File

#!/usr/bin/env python3
INPUT_FILE = 'input'
def main():
content = map(str.strip, open(INPUT_FILE, 'r').readlines())
score = 0
for line in content:
c1 = line[:len(line)//2]
c2 = line[len(line)//2:]
for char in c1:
if char in c2:
print(char)
if char.islower():
score += ord(char) - 96
else:
score += ord(char) - 38
break
print(score)
if __name__ == '__main__':
main()