Overlap in python

Gregor Lingl gregor.lingl at aon.at
Tue Aug 4 16:54:16 EDT 2009


DuaneKaufman schrieb:
> On Aug 4, 1:15 pm, Jay Bird <jay.bird0... at gmail.com> wrote:
...
> For instance the interval module found at: http://members.cox.net/apoco/interval/
> can be put to use:
> 
> Given your data above:
>> part name   location
>> a                  5-9
>> b                  7-10
>> c                  3-6
> 
> from interval import Interval
>>>> a_int=Interval(5,9)
>>>> b_int=Interval(7,10)
>>>> c_int=Interval(3,6)
>>>> a_int.overlaps(b_int)
> True
>>>> a_int.overlaps(c_int)
> True
>>>> b_int.overlaps(c_int)
> False

As my proposed solution shows this approach can
be done with on board means of Python (namely
the set type). This would be quite different though,
if you had floating point boundaries of the intervals.

Regards,
Gregor

> 
> Duane



More information about the Python-list mailing list