Orthogonal rectangles are those with edges parallel to the axes of the cartesian plane. Two rectangles may intersect with each other when there are points that are over or inside both of them. They do not intersect when they do not have common points.
The above figure shows four orthogonal rectangles with edges parallel to the x and y axes. The one with the bottom-left corner at (1,1) and top-right corner at (4,3) intersects with the bottom-left corner at (3,2) and top-right corner at (6,4). The one with the bottom-left corner at (7,1) and top-right corner at (9,3) does not intersect with the bottom-left corner at (10,2) and top-right corner at (11,3).
Write a program that given the bottom-left and top-right corners of two rectangles computes whether they intersect.
Input will consist of several lines each with eight integers x₀, y₀, x₁, y₁, x₂, y₂, x₃ and y₃ where the first rectangle has the bottom-left coordinate of (x₀,y₀) and top-right coordinate of (x₁,y₁) and the second rectangle has the bottom-left coordinate of (x₂,y₂) and top-right coordinate of (x₃,y₃).
For each line of input
there should be a line of output with either yes
or no
depending on whether the two rectangles intersect.
Example Input
1 1 4 3 3 2 6 4
10 2 11 3 7 1 9 3
Example Output
yes
no
try next: bool-calc
Copyright © 2020-2021 Rudy Matela
All rights reserved