Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Calculate overlap between 2 ranges of numbers

by jdporter (Canon)
on Oct 22, 2011 at 21:40 UTC ( #933106=note: print w/ replies, xml ) Need Help??


in reply to Calculate overlap between 2 ranges of numbers

You could use Set::IntSpan:

use Set::IntSpan; my $r1 = Set::IntSpan->new([ 5 .. 15 ]); my $r2 = Set::IntSpan->new([ 2 .. 20 ]); my $i = $r1->intersect($r2); if ( !$i->empty and ( $i->max - $i->min ) >= 5 ) # criteria { print "hit\n"; } else { print "miss\n"; }
I reckon we are the only monastery ever to have a dungeon stuffed with 16,000 zombies.


Comment on Re: Calculate overlap between 2 ranges of numbers
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://933106]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (11)
As of 2015-07-07 12:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (88 votes), past polls