Files
advent-of-code/2022/04/part1
2022-12-04 18:03:18 +00:00

21 lines
392 B
Python
Executable File

#!/usr/bin/env python
def build_range(text):
first, last = text.split("-")
return range(int(first), int(last)+1)
count = 0
with open('input') as f:
for line in f:
aS, bS = line.rstrip().split(",")
a = build_range(aS)
b = build_range(bS)
if (a[0] in b and a[-1] in b) or (b[0] in a and b[-1] in a):
count = count + 1
print(count)