Files
python-aoc-2022/day04/part1.py
Sebastian Seedorf c3050cb4fe Day 04 (minified)
2022-12-05 10:42:53 +01:00

12 lines
391 B
Python

#!/usr/bin/env python3
lines = (x.strip() for x in open("input.txt"))
s = 0
for line in lines:
a, b, x, y = map(int, line.replace(',', '-').split('-'))
s += 1 if b >= x <= a <= y >= b or y >= a <= x <= b >= y else 0
print(s)
print(sum(b >= x <= a <= y >= b or y >= a <= x <= b >= y for a, b, x, y in (map(int, l.strip().replace(',', '-').split('-')) for l in open("input.txt"))))