day 3 first answer
This commit is contained in:
24
03/c.py
Normal file
24
03/c.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import os
|
||||
|
||||
f = open(os.path.dirname(__file__)+"/input.txt", "r")
|
||||
|
||||
tot = 0
|
||||
tot2 = 0
|
||||
|
||||
priorities = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
|
||||
|
||||
commons = ''
|
||||
|
||||
rucksacks = f.read().splitlines()
|
||||
|
||||
for data in rucksacks:
|
||||
left = data[:len(data)//2]
|
||||
right = data[len(data)//2:]
|
||||
print(str(left) + " " + str(right))
|
||||
|
||||
common = ''.join(set(left).intersection(right))
|
||||
|
||||
tot = tot + priorities.rfind(common)+1
|
||||
|
||||
print(tot)
|
||||
Reference in New Issue
Block a user