Move into 2022 folder
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
def priority(item):
|
||||
if item < 'a':
|
||||
# uppercase
|
||||
return ord(item)-38
|
||||
else:
|
||||
# lowercase
|
||||
return ord(item)-96
|
||||
|
||||
totaal = 0
|
||||
with open("input.txt", "r") as f:
|
||||
for line in f.readlines():
|
||||
line = line.strip("\n")
|
||||
h = int(len(line)/2)
|
||||
left = line[:h]
|
||||
right = line[h:]
|
||||
for c in left:
|
||||
if c in right:
|
||||
totaal += priority(c)
|
||||
print(c)
|
||||
break
|
||||
print(totaal)
|
||||
Reference in New Issue
Block a user