Move into 2022 folder
This commit is contained in:
@@ -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)
|
||||
@@ -1,4 +1,3 @@
|
||||
elves = []
|
||||
count = 0
|
||||
with open("input.txt", "r") as f:
|
||||
for line in f.readlines():
|
||||
@@ -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)
|
||||
Reference in New Issue
Block a user