AdventOfCode/2022/day3/day3_part1.py

19 lines
408 B
Python

import sys
import numpy as np
import pprint, string
arr = []
alpha=list(string.ascii_letters)
values=[]
with open(sys.argv[1]) as f:
for l in f:
line=l.split()[0]
first, second = line[:len(line)//2],line[len(line)//2:]
shared=list(set(first)&set(second))[0]
index=alpha.index(shared)+1
values.append(index)
arr.append([first,second,shared,int(index)])
#pprint.pprint(arr)
print(sum(values))