simpler version of 4-1
This commit is contained in:
@@ -0,0 +1,25 @@
|
|||||||
|
elves = []
|
||||||
|
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)
|
||||||
Reference in New Issue
Block a user