Collaps arrays/ list of intergers

Rock Neurotiko miguelglafuente at gmail.com
Tue Aug 19 13:27:23 EDT 2014


Hi,

I made a fast implementation (I'm sure that can be done better) but it
works (for what I understood).

Is tested in Python3.4, if you will execute in Python 2.x, or don't have
mypy or don't like it, you always can remove the function annotations :)

http://gist.github.com/rockneurotiko/017044d907242c2e0482

There are all the code and some own-tests :)

I hope that this is what you was asking for :)

Cheers!




2014-08-19 18:22 GMT+02:00 Peter Pearson <ppearson at nowhere.invalid>:

> 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.
> --
> https://mail.python.org/mailman/listinfo/python-list
>



-- 
Miguel García Lafuente - Rock Neurotiko

Do it, the devil is in the details.
The quieter you are, the more you are able to hear.
Happy Coding. Code with Passion, Decode with Patience.
If we make consistent effort, based on proper education, we can change the
world.

El contenido de este e-mail es privado, no se permite la revelacion del
contenido de este e-mail a gente ajena a él.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20140819/4ed09987/attachment.html>


More information about the Python-list mailing list