I'm training with a website which ask me to make a program which will ask for the coords of two rectangles and check if the rectangles intersect. Then, when I send the program, the website tests it a few times. It asks for the x min, x max, y min and y max of A rectangle and then, B rectangle.
Here's what I do:
xmin_a = int(input())
xmax_a = int(input())
ymin_a = int(input())
ymax_a = int(input())
xmin_b = int(input())
xmax_b = int(input())
ymin_b = int(input())
ymax_b = int(input())
if xmin_a < xmax_b <= xmax_a and (ymin_a < ymax_b <= ymax_a or ymin_a <= ymin_b < ymax_a):
print('YES')
elif xmin_a <= xmin_b < xmax_a and (ymin_a < ymax_b <= ymax_a or ymin_a <= ymin_b < ymax_a):
print('YES')
elif xmin_b < xmax_a <= xmax_b and (ymin_b < ymax_a <= ymax_b or ymin_b <= ymin_a < ymax_b):
print('YES')
elif xmin_b <= xmin_a < xmax_b and (ymin_b < ymax_a <= ymax_b or ymin_b <= ymin_a < ymax_b):
print('YES')
else:
print('NO')
Unfortunately, it doesn't work and I don't get why. Any idea?
PS: http://data.france-ioi.org/Task/7b0ee4fb57949c3db1f694afcef9d1a1//exemple.png