We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Overlap

Time to write the logic that determines if two rectangles overlap!

Assignment

Complete the overlaps(self, rect: "Rectangle") -> bool method. It should check if the current rectangle (self) overlaps a given rectangle (rect).

Return True if self overlaps any part of rect, including just touching sides. Return False otherwise.

Tips

Each comparison has two parts:

  1. Pick one edge from self and one edge from rect
  2. Use the getter method for each edge

For example, to check if self's left side is on or to the left of rect's right side, compare self's left edge getter to rect's right edge getter.

All four of these conditions must be True:

  • self's left side is on or to the left of rect's right side
  • self's right side is on or to the right of rect's left side
  • self's top side is on or above rect's bottom side
  • self's bottom side is on or below rect's top side