aoc2022/04/2022-12-04-AB.py

14 lines
368 B
Python
Raw Normal View History

2022-12-04 11:14:31 +00:00
#!/usr/bin/env python3
result = [0,0]
import re
for l in open("04/i").readlines():
a = list(map(int,re.split("[,-]",l.strip())))
b = len(set(range(a[0],a[1]+1)).intersection(range(a[2],a[3]+1)))
if b == len(range(a[0],a[1]))+1 or b == len(range(a[2],a[3]))+1:
result[0]+=1
result[1]+=1
elif b != 0:
result[0]+=1
print(result)