Added old 2022 AoC solves
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
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))
|
||||
@@ -0,0 +1,21 @@
|
||||
import sys, pprint, string
|
||||
arr = []
|
||||
alpha=list(string.ascii_letters)
|
||||
values_part1=[]
|
||||
values_part2=[]
|
||||
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_part1.append(index)
|
||||
arr.append([line,first,second,shared,int(index)])
|
||||
|
||||
print(sum(values_part1))
|
||||
|
||||
for i in range(0,len(arr),3):
|
||||
shared=list(set(arr[i][0])&set(arr[i+1][0])&set(arr[i+2][0]))[0]
|
||||
values_part2.append(int(alpha.index(shared)+1))
|
||||
|
||||
print(sum(values_part2))
|
||||
Reference in New Issue
Block a user