In Python, you can get the numbers in a range by calling range(x,y). But given two ranges, say 5-15, and 10-20 how can you get all the numbers 5-20 without duplicates? The ranges may also be disjoint.
I could concat all the results and then uniquify the list, but is that the fastest solution?
Or if you want a more general expansion of the lists to their elements for inclusion in the set:
And I found a way to compose it all in one line:
Is sorting necessary? It’s just expository, but then I don’t see that sets necessarily output in sorted order: