CPSC120A
Fundamentals of Computer Science I

Post-lab 13

Boolean Operators

In video games, different objects are often represented as rectangles to simplify testing if two object are intersecting. One common method for testing if two rectangles are overlapping involves projecting the two rectangles onto a lower dimensional line and testing for overlap. In this post-lab, you will write a simple function to compute overlaps on a 1-dimensional number line, in order to demonstrate your understanding of Boolean operators.

Details

Create a function called are_overlapping(min1, max1, min2, max2) in a file called overlap.py. The function should return True if the range of numbers [min1, max1] overlaps with the range of numbers [min2, max2]. The function should return False otherwise. In more mathematical terms, there is an overlap if there is any real number that is in the range [min1, max1] and in the range [min2, max2].

Test your function by calling the function multiple times with different parameters. Make sure you follow the course's code conventions.

Test Cases

Function Parameters Expected Output
0, 1, 2, 3 False
0, 2, 1, 3 True
0, 1, 1, 2 True
2, 3, 0, 1 False
1, 3, 0, 2 True
1, 2, 0, 1 True

Submission

Submit your program as a .py file on the course Inquire page before class on Wednesday October 1st.