#! perl -slw use strict; my @ranges = map{ my $a = rand( 900 ); [ $a, $a + rand( 1000 - $a ) ] } 1 .. 7; print "$_ : [ @{ $ranges[ $_ ]} ]" for 0 .. 6; my @overlaps; for my $i1 ( 0 .. 6 ) { for my $i2 ( $i1+1 .. 6 ) { unless( $ranges[ $i1 ][ 0 ] > $ranges[ $i2 ][ 1 ] or $ranges[ $i1 ][ 1 ] < $ranges[ $i2 ][ 0 ] ) { push @{ $overlaps[ $i1 ] }, $i2; } } } defined $overlaps[ $_ ] and print "$_ overlaps with @{ $overlaps[ $_ ] }" for 0 .. 6; __END__ c:\test>junk39 0 : [ 752.67333984375 781.958845257759 ] 1 : [ 45.5657958984375 108.800557162613 ] 2 : [ 574.887084960938 742.659308388829 ] 3 : [ 190.887451171875 585.887861438096 ] 4 : [ 20.7916259765625 200.777344871312 ] 5 : [ 306.353759765625 756.753877364099 ] 6 : [ 721.856689453125 821.619211696088 ] 0 overlaps with 5 6 1 overlaps with 4 2 overlaps with 3 5 6 3 overlaps with 4 5 5 overlaps with 6

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re: find which ranges share at least one common value by BrowserUk
in thread find which ranges share at least one common value by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.