(a1, a2, b1, b2)
return a_min <= b_min <= a_max or b_min <= a_min <= b_max or \
           a_min <= b_max <= a_max or b_min <= a_max <= b_max
Check if ranges a1-a2 and b1-b2 overlap.
Check if ranges a1-a2 and b1-b2 overlap.
Check if ranges a1 - a2 and b1 - b2 overlap .
def overlap(a1, a2, b1, b2):
    """
    Check if ranges a1-a2 and b1-b2 overlap.
    """
    a_min = min(a1, a2)
    a_max = max(a1, a2)
    b_min = min(b1, b2)
    b_max = max(b1, b2)
    
    return a_min <= b_min <= a_max or b_min <= a_min <= b_max or \
           a_min <= b_max <= a_max or b_min <= a_max <= b_max
def overlap ( a1 , a2 , b1 , b2 ) : a_min = min ( a1 , a2 ) a_max = max ( a1 , a2 ) b_min = min ( b1 , b2 ) b_max = max ( b1 , b2 ) return a_min <= b_min <= a_max or b_min <= a_min <= b_max or a_min <= b_max <= a_max or b_min <= a_max <= b_max