Move into 2022 folder

This commit is contained in:
Mark Hoekveen
2024-11-11 09:05:01 +01:00
parent 9dd6a4f275
commit e0d955ec6f
28 changed files with 5 additions and 11 deletions
View File
View File
View File
View File
View File
View File
View File
+3 -3
View File
@@ -6,7 +6,7 @@ def priority(item):
# lowercase
return ord(item)-96
priorities = []
totaal = 0
with open("input.txt", "r") as f:
for line in f.readlines():
line = line.strip("\n")
@@ -15,7 +15,7 @@ with open("input.txt", "r") as f:
right = line[h:]
for c in left:
if c in right:
priorities.append(priority(c))
totaal += priority(c)
print(c)
break
print(sum(priorities))
print(totaal)
View File
View File
-1
View File
@@ -1,4 +1,3 @@
elves = []
count = 0
with open("input.txt", "r") as f:
for line in f.readlines():
+2 -7
View File
@@ -1,4 +1,3 @@
elves = []
count = 0
with open("input.txt", "r") as f:
for line in f.readlines():
@@ -6,11 +5,7 @@ with open("input.txt", "r") as f:
# Some python magic to split out the strings and convert them to integers
pair = [x.split("-") for x in line.split(",")]
pair = [[int(y) for y in x] for x in pair]
elves.append(pair)
# Elves is now a list of list of lists.
for elf in elves:
if ((elf[0][0] <= elf[1][0] and elf[0][1] >= elf[1][1]) or
(elf[1][0] <= elf[0][0] and elf[1][1] >= elf[0][1])):
print(elf)
if ((pair[0][0] <= pair[1][0] and pair[0][1] >= pair[1][1]) or
(pair[1][0] <= pair[0][0] and pair[1][1] >= pair[0][1])):
count += 1
print(count)
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File
View File