How to identify which numbers in a list are within each others' range

Paul Rubin http
Thu Jan 31 11:24:44 EST 2008


erikcw <erikwickstrom at gmail.com> writes:
> What is the best way to in python to identify the list items that
> overlap and the items that don't overlap with any other.

This sounds like a homework problem, so the first thing I'll suggest
is that you figure out exactly what it means for two of those
intervals to overlap.  That should let you write a simple program that
gets the right answer, but that can run slowly if the number of lists
gets large.  The next thing to do after that is figure out how to
speed it up, if necessary.  But do the first part first.



More information about the Python-list mailing list