aoc
/
2022
1
0
Fork 0
2022/day04.py

20 lines
400 B
Python
Raw Normal View History

2022-12-04 10:10:52 +00:00
import fileinput
2022-12-24 14:59:27 +00:00
def main():
part1, part2 = 0, 0
2022-12-04 10:10:52 +00:00
2022-12-24 14:59:27 +00:00
for line in fileinput.input():
a, b = line.split(",", 1)
a1, a2 = [int(x) for x in a.split("-", 1)]
b1, b2 = [int(x) for x in b.split("-", 1)]
2022-12-04 10:10:52 +00:00
2022-12-24 14:59:27 +00:00
part1 += (a1 >= b1 and b2 >= a2) or (b1 >= a1 and a2 >= b2)
part2 += a1 <= b2 and a2 >= b1
2022-12-04 10:10:52 +00:00
2022-12-24 14:59:27 +00:00
print(part1, part2)
if __name__ == "__main__":
main()