CPSC120A
Fundamentals of Computer Science I

Post-lab 15

Logical Operators

Do one of the following programming problems:

Range Overlaps

Write a function called range_overlaps(min1, max1, min2, max2) that returns True or False depending on whether the range [min1, max1] overlaps with the range [min2, max2]. There is an overlap if there is any real number that is in the range [min1, max1] and in the range [min2, max2].


Rectangle Overlaps

Write a function called rectangle_overlaps(x1, y1, width1, height1, x2, y2, width2, height2) that returns True or False depending on whether the rectangle with center (x1, y1) and dimensions (width1, height1) overlaps with the rectangle with center (x2, y2) and dimensions (width2, height2). Assume that if the rectangle edges precisely touch, then the rectangles are overlapping.