Is a merge interval function available?

Alf P. Steinbach alfps at start.no
Thu Feb 11 22:37:46 CET 2010


* Jonathan Gardner:
> On Feb 10, 3:23 pm, Peng Yu <pengyu... at gmail.com> wrote:
>> I'm wondering there is already a function in python library that can
>> merge intervals. For example, if I have the following intervals ('['
>> and ']' means closed interval as inhttp://en.wikipedia.org/wiki/Interval_(mathematics)#Excluding_the_end...)
>>
>> [1, 3]
>> [2, 9]
>> [10,13]
>> [11,12]
>>
>> I want to get the following merged intervals.
>>
>> [1,9]
>> [10,13]
>>
>> Could somebody let me know if there is a function in the python
>> library?
> 
> I vaguely recall a similar question a long time ago. Peng, is this a
> homework assignment?
> 
> Perhaps we should add a standard module called "homework". It can have
> functions for all the different homework assignments we see on
> c.l.python. We can simply point people to this module and then can
> include the code in their answers.

If it's possible, there was/is this guy over in clc.c++ who responded/responds 
to homework questions with the most advanced, convoluted and, except for 
misleading names, technically correct solutions.


Cheers,

- Alf



More information about the Python-list mailing list