I think you misunderstood the question, probably due my poor explanation. You have to look both sides at the same time in a single range. You can't pick one range that has a far right side and another that has a far left side. In other words: for each position i we are looking for the (half) size of the minimal (odd-sized) window which is centered around i, and is not contained by any (single) range. You can't 'split' the containment between two ranges.

Going back to the example of position 1:

half size 0: there exists a range that covers 1,1
half size 1: there exists a range that covers 35,2
half size 2: there exists a range that covers 34,3
...
half size 8: there exists a range that covers 28,9 (e.g. 28,10)
half size 9: there is NO range that covers 27,10. DONE!

I hope it's more clear now.

(p.s. in your ASCII art it seems as if MAX=36, not 35, doesn't it?)


In reply to Re^2: Can I speed this up? (Algorithm error) by daverave
in thread Can I speed this up? (repetitively scanning ranges in a large array) by daverave

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.