Moved 2022 to own dir

This commit is contained in:
2023-11-30 19:20:34 +02:00
parent e700358bda
commit 6bd452a4ec
16 changed files with 0 additions and 0 deletions

21
2022/03/c.py Normal file
View File

@@ -0,0 +1,21 @@
import os
rucksacks = open(os.path.dirname(__file__) +
"/input.txt", "r").read().splitlines()
tot, tot2 = 0, 0
priorities = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
for data in rucksacks:
tot += priorities.rfind(''.join(set(data[:len(data)//2])
& set(data[len(data)//2:])))+1
print("First answer: " + str(tot))
for i in range(0, len(rucksacks), 3):
three = rucksacks[i:i+3]
tot2 += priorities.rfind(''.join(set(three[0])
& set(three[1]) & set(three[2])))+1
print("Second answer: " + str(tot2))