def intersect(a, b):
    """
    Check if two rectangles intersect
    """
    if a[x0] == a[x1] or a[y0] == a[y1]:
        return False
    if b[x0] == b[x1] or b[y0] == b[y1]:
        return False
    return a[x0] <= b[x1] and b[x0] <= a[x1] and a[y0] <= b[y1] and b[y0] <= a[y1]
Check if two rectangles intersect