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
+24
View File
@@ -0,0 +1,24 @@
count = 0
with open("input.txt", "r") as f:
for line in f.readlines():
line = line.strip("\n")
# "A-B,C-D"
twoelves = line.split(",")
# ["A-B", "C-D"]
# "A-B"
leftelf = twoelves[0].split("-")
# ["A", "B"]
lb1 = int(leftelf[0])
ub1 = int(leftelf[1])
# "C-D"
rightelf = twoelves[1].split("-")
# ["C", "D"]
lb2 = int(rightelf[0])
ub2 = int(rightelf[1])
if ((lb1 <= lb2 and ub1 >= ub2) or # Elf 1 fully covers elf 2
(lb2 <= lb1 and ub2 >= ub1)): # Elf 2 fully covers elf 1
count += 1
print(count)