Fredrik Lundh wrote:
> def overlap(a, b):
> return a[1] > b[0] and a[0] < b[1]
Assuming that x[1] can't be smaller than x[0], this
is the right way to compare two ranges. Well, I guess
you need to figure out the borderline cases. Is it
a[1] > b[0] or a[1] >= b[0] which is relevant?
An
Robin Haswell wrote:
> I can think of lots of ways to do this but it's in a tight loop so I need
> it to be as efficient as possible. Any help welcome :-)
There are 24 possibilities of having 4 numbers in a row, and
the following 6 of them describe nonempty intervals (the remaining
18 are obtaine
Thanks guys, you've all been very helpful :-)
-Rob
--
http://mail.python.org/mailman/listinfo/python-list
Robin Haswell wrote:
> Hey guys
>
> I was wondering if you could give me a hand with something. If I have two
> tuples that define a range, eg: (10, 20), (15, 30), I need to determine
> whether the ranges overlap each other.
def overlap(a,b):
return a[0] <= b[0] <= a[1] or b[0] <= a[0] <= b[1
Robin Haswell wrote:
> I was wondering if you could give me a hand with something. If I have two
> tuples that define a range, eg: (10, 20), (15, 30), I need to determine
> whether the ranges overlap each other. The algo needs to catch:
>
> (10, 20) (15, 25)
> (15, 25) (10, 20)
> (10, 25) (15, 20)
[Robin Haswell]
| I was wondering if you could give me a hand with something.
| If I have two
| tuples that define a range, eg: (10, 20), (15, 30), I need to
| determine
| whether the ranges overlap each other. The algo needs to catch:
|
| (10, 20) (15, 25)
| (15, 25) (10, 20)
| (10, 25) (15, 2
On Thu, 16 Feb 2006 15:22:15 +, Robin Haswell wrote:
> Hey guys
>
> I was wondering if you could give me a hand with something. If I have two
> tuples that define a range, eg: (10, 20), (15, 30), I need to determine
> whether the ranges overlap each other. The algo needs to catch:
>
> (10, 2
Hey guys
I was wondering if you could give me a hand with something. If I have two
tuples that define a range, eg: (10, 20), (15, 30), I need to determine
whether the ranges overlap each other. The algo needs to catch:
(10, 20) (15, 25)
(15, 25) (10, 20)
(10, 25) (15, 20)
and
(15, 20) (10, 25)
I