On Feb 8, 1:48 pm, Boris Borcic <[EMAIL PROTECTED]> wrote: > Arnaud Delobelle wrote: > > (...) > > > > > from itertools import chain > > > def overlaps(lst): > > bounds = chain(*(((x[1],i), (x[2], i)) for i,x in enumerate(lst))) > > imho, this is a uselessly painful equivalent of > > bounds = ((x[k],i) for i,x in enumerate(lst) for k in (1,2)) > > Cheers, BB
I did mention that it was awkward (but at the time I just wrote what came to mind) - thank you for providing a much improved version. It doesn't deter from the fact that the algorithm is of optimal complexity (modulo sorting of the list). -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list