AOC/2022/day04/part1.py
2024-08-29 17:12:29 +02:00

20 lines
536 B
Python

f = open("file");
s = f.read();
f.close();
menfou = 0;
for pair in s.splitlines():
elfs = pair.split(",");
values = elfs[0].split("-")
start1 = int(values[0]);
end1 = int(values[1]);
values = elfs[1].split("-")
start2 = int(values[0]);
end2 = int(values[1]);
if (start2 <= start1 <= end2 and end1 <= end2):
print (start2, start1, end1, end2)
menfou += 1;
elif (start1 <= start2 <= end1 and end2 <= end1):
print (start1, start2, end2, end1)
menfou += 1;
print(menfou);