Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
9-liner: enumerate each interval solution in Clear category for Create Intervals by Stensen
def create_intervals(ints):
ints, explicit_inervals, result = sorted(ints), [0], []
for i, (j, k) in enumerate(zip(ints, ints[1:] + ints[:1])):
if k - j != 1:
explicit_inervals.append(i+1)
for i, j in zip(explicit_inervals, explicit_inervals[1:]):
interv = ints[i:j]
result.append((interv[0], interv[-1]))
return result
Nov. 20, 2020