Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Peter Pearson Newsgroups: comp.lang.python Subject: Re: Collaps arrays/ list of intergers Date: 19 Aug 2014 16:22:53 GMT Lines: 33 Message-ID: References: X-Trace: individual.net ePeB3JtRqCtMi2ANPQhIFwPZNblm6WXMcN7ZW1sD7OyR16W7sr Cancel-Lock: sha1:GrFXhGHzDCG+hxbDiKbmWYxk1Ug= User-Agent: slrn/pre1.0.0-18 (Linux) Xref: csiph.com comp.lang.python:76573 On Tue, 19 Aug 2014 05:54:24 -0700 (PDT), Jurgens de Bruin wrote: > > I do hope somebody can help me with the following: > I have the followings lists which represent the upper and lower value > of a range/array. > > a = [1,50] > b = [75,150] > c = [25,42] > d = [120,149] > e = [35,55] > > What I would like to happen is that overlapping range will "collapse" > to a single range meaning the above list would become: > > as list a,c and e overlap they can be represented by > f = [1,55] > as list b and d overlap they can be represented by > g = [75,150] Is your question about (a) identifying overlapping subsets of ranges, or (b) collapsing such subsets once you have identified them? What output would you want if the inputs were . . . a = [1,50] b = [2,10] c = [40,60] ? -- To email me, substitute nowhere->spamcop, invalid->net.