parent
bb4e3b9b70
commit
2af2e1b07d
@ -0,0 +1,6 @@
|
||||
2-4,6-8
|
||||
2-3,4-5
|
||||
5-7,7-9
|
||||
2-8,3-7
|
||||
6-6,4-6
|
||||
2-6,4-8
|
@ -0,0 +1,9 @@
|
||||
lines = open("input.txt", "r").read().splitlines()
|
||||
contains = 0
|
||||
for line in lines:
|
||||
lots = [int(i) for i in line.replace(",", "-").split("-")]
|
||||
if (lots[0] >= lots[2]) and (lots[1] <= lots[3]):
|
||||
contains = contains + 1
|
||||
elif lots[0] <= lots[2] and lots[1] >= lots[3]:
|
||||
contains = contains + 1
|
||||
print(contains)
|
@ -0,0 +1,13 @@
|
||||
lines = open("input.txt", "r").read().splitlines()
|
||||
overlap = 0
|
||||
|
||||
for line in lines:
|
||||
lota, lotb = line.split(",")
|
||||
lota = [int(i) for i in lota.split("-")]
|
||||
lotb = [int(i) for i in lotb.split("-")]
|
||||
intersect = set(range(lota[0], lota[1] + 1)).intersection(
|
||||
set(range(lotb[0], lotb[1] + 1))
|
||||
)
|
||||
if len(intersect) > 0:
|
||||
overlap = overlap + 1
|
||||
print(overlap)
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue