I can't get an example running, (its late here), but I think to get all possible paths from the beginning number to the end number would involve a powerset. Something like if there are 8 numbers from lowest to highest, then you would need to generate the powerset of the 6 numbers between the highest and lowest numbers - 2^6 = 64 possible paths.

List::PowerSet can do this for you.

Here is a small program using the data you provided, (followed by the results of the run).

#!/usr/bin/perl use strict; use warnings; use List::PowerSet qw(powerset); my $nums = '0-200 200-400 400-600 600-800 800-1000 1000-2000 0,1800'; my %hash; @hash{ split /\D+/, $nums } = (); my @sorted = sort {$a<=> $b} keys %hash; my $start = shift @sorted; my $end = pop @sorted; my $ps = powerset(@sorted); for my $set (@$ps) { print join("-", $start, @$set, $end), "\n"; } __END__ 0-200-400-600-800-1000-1800-2000 0-400-600-800-1000-1800-2000 0-200-600-800-1000-1800-2000 0-600-800-1000-1800-2000 0-200-400-800-1000-1800-2000 0-400-800-1000-1800-2000 0-200-800-1000-1800-2000 0-800-1000-1800-2000 0-200-400-600-1000-1800-2000 0-400-600-1000-1800-2000 0-200-600-1000-1800-2000 0-600-1000-1800-2000 0-200-400-1000-1800-2000 0-400-1000-1800-2000 0-200-1000-1800-2000 0-1000-1800-2000 0-200-400-600-800-1800-2000 0-400-600-800-1800-2000 0-200-600-800-1800-2000 0-600-800-1800-2000 0-200-400-800-1800-2000 0-400-800-1800-2000 0-200-800-1800-2000 0-800-1800-2000 0-200-400-600-1800-2000 0-400-600-1800-2000 0-200-600-1800-2000 0-600-1800-2000 0-200-400-1800-2000 0-400-1800-2000 0-200-1800-2000 0-1800-2000 0-200-400-600-800-1000-2000 0-400-600-800-1000-2000 0-200-600-800-1000-2000 0-600-800-1000-2000 0-200-400-800-1000-2000 0-400-800-1000-2000 0-200-800-1000-2000 0-800-1000-2000 0-200-400-600-1000-2000 0-400-600-1000-2000 0-200-600-1000-2000 0-600-1000-2000 0-200-400-1000-2000 0-400-1000-2000 0-200-1000-2000 0-1000-2000 0-200-400-600-800-2000 0-400-600-800-2000 0-200-600-800-2000 0-600-800-2000 0-200-400-800-2000 0-400-800-2000 0-200-800-2000 0-800-2000 0-200-400-600-2000 0-400-600-2000 0-200-600-2000 0-600-2000 0-200-400-2000 0-400-2000 0-200-2000 0-2000

In reply to Re: search overlap paths by Cristoforo
in thread search overlap paths 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.