Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #76594

Re: Collaps arrays/ list of intergers

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <miguelglafuente@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.051
X-Spam-Evidence '*H*': 0.90; '*S*': 0.00; 'output': 0.05; '(b)': 0.07; 'annotations': 0.09; 'gente': 0.09; 'url:github': 0.09; 'python': 0.11; "(i'm": 0.16; 'cheers!': 0.16; 'devil': 0.16; 'inputs': 0.16; 'substitute': 0.16; 'wrote:': 0.18; 'aug': 0.22; '(a)': 0.24; 'question': 0.24; '&gt;': 0.26; '(for': 0.26; 'asking': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'subject:list': 0.30; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'code': 0.31; 'them?': 0.31; 'lists': 0.32; 'url:python': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'are,': 0.36; 'consistent': 0.36; 'done': 0.36; 'url:listinfo': 0.36; 'hi,': 0.36; 'url:org': 0.36; 'list': 0.37; 'represent': 0.38; 'somebody': 0.38; 'to:addr:python-list': 0.38; 'skip:& 20': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'url:mail': 0.40; 'remove': 0.60; 'hope': 0.61; 'lower': 0.61; 'details.': 0.61; 'range': 0.61; 'world.': 0.61; 'such': 0.63; 'happen': 0.63; 'skip:n 10': 0.64; 'more': 0.64; 'este': 0.70; 'upper': 0.74; 'collapsing': 0.84; 'education,': 0.96
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=PReKsd+CYgJNHaxn5xYSFOCTqndYuG2cNJvvcAMw6sk=; b=GqYcoNy0vvtDSPZiM46PDXZpjXTlthvaJUc4nKcu4/kcGl1NDPTsWvtNgrYIRo6Pbn fzU1E9X/bAckfOg0Q4EE0jsvk0DelAB9rgYxL+2BYynzuy0edvgnTqxPwIn365bIvR4G ewp5pC4RgvEJgdMqEyU5ljoO9BuvqQ3qmW13x9f/2/+1qtfhc9KEWjPnLXf+0fc46hzE 6HMMIlPtarct7PdIsMJv/OfhiWuEhf2EsqmN0bBLh6i97Dmxuzteo3Qp+bMvH+fKifsL pFl8lmwqX30RjSFKA/3AwF2eHUmcvbUcymo6cTomQgvyGGTedVhKxsNWFm0EMYWxo24M LLBQ==
X-Received by 10.152.44.230 with SMTP id h6mr37523124lam.51.1408469273590; Tue, 19 Aug 2014 10:27:53 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <c5hbutF3mg8U1@mid.individual.net>
References <fb9b097d-1a25-4f28-9b3f-61636e013a91@googlegroups.com> <c5hbutF3mg8U1@mid.individual.net>
From Rock Neurotiko <miguelglafuente@gmail.com>
Date Tue, 19 Aug 2014 19:27:23 +0200
Subject Re: Collaps arrays/ list of intergers
To python-list@python.org
Content-Type multipart/alternative; boundary=089e0158c3bebabf640500fece0e
X-Mailman-Approved-At Tue, 19 Aug 2014 20:39:41 +0200
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.13160.1408473581.18130.python-list@python.org> (permalink)
Lines 173
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1408473581 news.xs4all.nl 2857 [2001:888:2000:d::a6]:42274
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:76594

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

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@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.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Collaps arrays/ list of intergers Jurgens de Bruin <debruinjj@gmail.com> - 2014-08-19 05:54 -0700
  Re: Collaps arrays/ list of intergers Peter Pearson <ppearson@nowhere.invalid> - 2014-08-19 16:22 +0000
    Re: Collaps arrays/ list of intergers Rock Neurotiko <miguelglafuente@gmail.com> - 2014-08-19 19:27 +0200
  Re: Collaps arrays/ list of intergers Peter Otten <__peter__@web.de> - 2014-08-19 19:52 +0200
  Re: Collaps arrays/ list of intergers Denis McMahon <denismfmcmahon@gmail.com> - 2014-08-19 19:05 +0000

csiph-web