This commit is contained in:
DUEFON 2022-12-05 20:40:46 +01:00 committed by Eivind Øksnevad
parent 621653a442
commit 28e244e1f2
2 changed files with 1018 additions and 0 deletions

18
four.py Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env python3
from useful import *
def does_overlap(l):
a, b, c, d = (int(n) for n in re.match(r'(\d+)-(\d+),(\d+)-(\d+)', l).groups())
u = set(i for i in range(a, b + 1))
v = set(i for i in range(c, d + 1))
return u & v == u or u & v == v
def sorta_overlap(l):
a, b, c, d = (int(n) for n in re.match(r'(\d+)-(\d+),(\d+)-(\d+)', l).groups())
u = set(i for i in range(a, b + 1))
v = set(i for i in range(c, d + 1))
return 1 if u & v else 0
ls = lines(open(0))
print(sum(does_overlap(l) for l in ls))
print(sum(sorta_overlap(l) for l in ls))

1000
input4 Normal file

File diff suppressed because it is too large Load Diff