# Rectangle Intersection: The Top-Edge Method Problem setter's solution: choose the rectangle with the highest top edge and test the other rectangle's top edge. The teaching notes also give projection and center-distance methods. Codex (GPT-6): retaining the top-edge method, removing nonstandard array initialization and using 64-bit coordinates consistently. ## Normalize endpoints and detect an empty intersection Represent each shape $X$ as the product of closed intervals $[l_X,r_X]\times[b_X,t_X]$ , using its left, right, bottom and top bounds. Zero-length intervals are allowed. Swap the shapes so that $t_A\ge t_B$ . Their intersection is empty exactly when at least one condition below holds: $$t_B