On Aug 4, 3:21 pm, Jay Bird wrote:
> Hi everyone,
>
> I wanted to thank you all for your help and *excellent* discussion. I
> was able to utilize and embed the script by Grigor Lingl in the 6th
> post of this discussion to get my program to work very quickly (I had
> to do about 20 comparisons pe
On 8/5/2009 10:56 AM, nn wrote:
On Aug 5, 7:13 am, Marcus Wanner wrote:
On 8/4/2009 6:09 PM, MRAB wrote:
>>> parts = [(5, 9, "a"), (7, 10, "b"), (3, 6, "c"), (15, 20, "d"),
(18, 23, "e")]
>>> parts.sort()
>>> parts
[(3, 6, 'c'), (5, 9, 'a'), (7, 10, 'b'), (15, 20, 'd'), (18, 23, 'e')]
>>>
Jay Bird wrote:
Hi everyone,
I wanted to thank you all for your help and *excellent* discussion. I
was able to utilize and embed the script by Grigor Lingl in the 6th
post of this discussion to get my program to work very quickly (I had
to do about 20 comparisons per data bin, with over 40K bin
Jay Bird wrote:
Hi everyone,
I've been trying to figure out a simple algorithm on how to combine a
list of parts that have 1D locations that overlap into a non-
overlapping list. For example, here would be my input:
part name location
a 5-9
b 7-10
c
On Aug 5, 7:13 am, Marcus Wanner wrote:
> On 8/4/2009 6:09 PM, MRAB wrote:
>
> > >>> parts = [(5, 9, "a"), (7, 10, "b"), (3, 6, "c"), (15, 20, "d"),
> > (18, 23, "e")]
> > >>> parts.sort()
> > >>> parts
> > [(3, 6, 'c'), (5, 9, 'a'), (7, 10, 'b'), (15, 20, 'd'), (18, 23, 'e')]
> > >>> # Merge
On 8/4/2009 6:09 PM, MRAB wrote:
>>> parts = [(5, 9, "a"), (7, 10, "b"), (3, 6, "c"), (15, 20, "d"),
(18, 23, "e")]
>>> parts.sort()
>>> parts
[(3, 6, 'c'), (5, 9, 'a'), (7, 10, 'b'), (15, 20, 'd'), (18, 23, 'e')]
>>> # Merge overlapping intervals.
>>> pos = 1
>>> while pos < len(parts):
Albert van der Horst:
>That is an algorithmic question and has little to do with Python.<
Yes, but comp.lang.python isn't comp.lang.c, that kind of questions
are perfectly fine here. They help keep this place from becoming
boring.
Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python
In article ,
Jay Bird wrote:
>Hi everyone,
>
>I've been trying to figure out a simple algorithm on how to combine a
>list of parts that have 1D locations that overlap into a non-
>overlapping list. For example, here would be my input:
>
>part name location
>a 5-9
>b
On Aug 4, 2:57 pm, Gregor Lingl wrote:
> Jay Bird schrieb:
>
>
>
>
>
> > Hi everyone,
>
> > I've been trying to figure out a simple algorithm on how to combine a
> > list of parts that have 1D locations that overlap into a non-
> > overlapping list. For example, here would be my input:
>
> > part
kj:
> # connect the nodes
> for i in range(len(parts) - 1):
> part_i = parts[i]
> for j in range(i + 1, len(parts)):
Note that's O(N^2), see the O(sort) standard solution by Mark
Dickinson.
Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list
In <78d86d92-d373-4163-a418-600a3eb36...@o15g2000yqm.googlegroups.com> Mark
Dickinson writes:
>On Aug 4, 7:15=A0pm, Jay Bird wrote:
>> Hi everyone,
>>
>> I've been trying to figure out a simple algorithm on how to combine a
>> list of parts that have 1D locations that overlap into a non-
>> ove
Jay Bird wrote:
Hi everyone,
I've been trying to figure out a simple algorithm on how to combine a
list of parts that have 1D locations that overlap into a non-
overlapping list. For example, here would be my input:
part name location
a 5-9
b 7-10
c
In Jay Bird
writes:
>Hi everyone,
>I've been trying to figure out a simple algorithm on how to combine a
>list of parts that have 1D locations that overlap into a non-
>overlapping list. For example, here would be my input:
>part name location
>a 5-9
>b 7-
On Aug 4, 9:03 pm, Mark Dickinson wrote:
> for i, (pt, startend, name) in enumerate(transitions):
Whoops. That line should just be:
for pt, startend, name in transitions:
The enumerate was accidentally left-over from a more
complicated version.
--
Mark
--
http://mail.python.org/mailman/lis
Mark Dickinson:
> # create sorted list of points where an interval is entered or left
> transitions = []
> for name, (start, stop) in input:
> transitions.extend([(start, 'Start', name), (stop, 'Stop', name)])
> transitions.sort()
>
> # scan list, accumulating blocks along the way.
Oh, right,
Gregor Lingl schrieb:
As my proposed solution shows this approach can
be done with on board means of Python (namely
the set type). This would be quite different though,
if you had floating point boundaries of the intervals.
... or if the intgers involved were very big :-(
Regards,
Gregor
DuaneKaufman schrieb:
On Aug 4, 1:15 pm, Jay Bird wrote:
...
For instance the interval module found at:
http://members.cox.net/apoco/interval/
can be put to use:
Given your data above:
part name location
a 5-9
b 7-10
c 3-6
from interval
Jay Bird:
> I've been trying to figure out a simple algorithm on how to combine a
> list of parts that have 1D locations that overlap into a non-
> overlapping list. For example, here would be my input:
>
> part name location
> a 5-9
> b 7-10
> c
On Aug 4, 1:15 pm, Jay Bird wrote:
> Hi everyone,
>
> I've been trying to figure out a simple algorithm on how to combine a
> list of parts that have 1D locations that overlap into a non-
> overlapping list. For example, here would be my input:
>
> part name location
> a 5-9
>
On Aug 4, 7:15 pm, Jay Bird wrote:
> Hi everyone,
>
> I've been trying to figure out a simple algorithm on how to combine a
> list of parts that have 1D locations that overlap into a non-
> overlapping list. For example, here would be my input:
>
> part name location
> a 5-9
>
Jay Bird schrieb:
Hi everyone,
I've been trying to figure out a simple algorithm on how to combine a
list of parts that have 1D locations that overlap into a non-
overlapping list. For example, here would be my input:
part name location
a 5-9
b 7-10
c
Jay Bird wrote:
Hi everyone,
I've been trying to figure out a simple algorithm on how to combine a
list of parts that have 1D locations that overlap into a non-
overlapping list. For example, here would be my input:
part name location
a 5-9
b 7-10
c
On 8/4/2009 2:46 PM, Ann wrote:
On Aug 4, 11:31 am, Marcus Wanner wrote:
On Aug 4, 2:15 pm, Jay Bird wrote:
Hi everyone,
I've been trying to figure out a simple algorithm on how to combine a
list of parts that have 1D locations that overlap into a non-
overlapping list. For example, here
On Aug 4, 11:31 am, Marcus Wanner wrote:
> On Aug 4, 2:15 pm, Jay Bird wrote:
>
>
>
> > Hi everyone,
>
> > I've been trying to figure out a simple algorithm on how to combine a
> > list of parts that have 1D locations that overlap into a non-
> > overlapping list. For example, here would be my i
On Aug 4, 2:15 pm, Jay Bird wrote:
> Hi everyone,
>
> I've been trying to figure out a simple algorithm on how to combine a
> list of parts that have 1D locations that overlap into a non-
> overlapping list. For example, here would be my input:
>
> part name location
> a 5-9
>
Hi everyone,
I've been trying to figure out a simple algorithm on how to combine a
list of parts that have 1D locations that overlap into a non-
overlapping list. For example, here would be my input:
part name location
a 5-9
b 7-10
c 3-6
d
26 matches
Mail list logo