Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Create Intervals (generator version) by Tinus_Trotyl
def intervals(data):
if data:
begin = end = min(data)
data -= {begin}
while end + 1 in data:
end += 1
data -= {end}
return [(begin, end)] + intervals(data)
return []
def create_intervals(data):
for interval in intervals(data): yield interval
June 26, 2020