You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`
import itertools
def merge(intervals):
new_intervals = []
# Checking that the list of intervals given is longer than 1
# As if there is only one interval we just return the list
if (len(intervals) <= 1):
return intervals
# Now we can iterate through the list assigning the merged
# Values to our new_intervals list
for a, b in itertools.combinations(intervals, 2):
new_intervals = x_overlap_y(a, b)
print(new_intervals)
def x_overlap_y(x, y):
a = x[0]
b = x[1]
c = y[0]
d = y[1]
if ((a - c) * (b - d) > 0):
return [[a, b], [c,d]]
else:
front = c if (a - c > 0) else a
back = b if (b - d > 0) else d
return [front, back]
`
No description provided.
The text was updated successfully, but these errors were encountered: