def overlap(a, b, x, y, inc=True):
    """
    Returns True if range [a,b] overlaps [x,y]

    inc: if True, treat [a,b] and [x,y] as inclusive
    """
    if inc:
        return (y >= a) and (x <= b)
    else:
        return (y > a) and (x < b)