I thought I understood the requirements, but some of the later comments and the talk of "dropping" arrays are making me wonder again. You said "the processing within each group involves processing every item against every other item within the group." So if an interval happens to span 6,7,8, you want to process 6&7, 6&8, and 7&8, right? But you want to make sure no pair is processed more than once?

If that's correct, then I'd picture it as a sliding window of size $interval+1, and I'd use a hash to keep track of which pairs of items have been processed. In pseudo-code, something like this:

create a hash to hold processed pairs, with a key like "3 4" to indicate that 3 has been processed against 4 get minimum and maximum key values (3 & 11 in this case) loop from minimum to maximum minus interval if interval contains more than one item for each pair of items in interval check hash to see if the pair has been processed if not process the pair mark the pair in the hash

No need to "drop" anything that I can see, since the sliding interval will move along to the next set. In your example, with an interval of 4, this would happen:

minimum = 3, maximum = 11, so loop from 3 to 7 first interval is 3-7, so includes 3,4,6,7 process 3 & 4 process 3 & 6 process 3 & 7 process 4 & 6 process 4 & 7 process 6 & 7 next interval is 4-8, so includes 4,6,7,8 skip 4 & 6, already done skip 4 & 7, already done process 4 & 8 skip 6 & 7, already done process 6 & 8 process 7 & 8 next interval is 5-9, so includes 6,7,8 skip 6 & 7, already done skip 6 & 8, already done skip 7 & 8, already done next interval is 6-10, so includes 6,7,8 skip 6 & 7, already done skip 6 & 8, already done skip 7 & 8, already done next interval is 7-11, so includes 7,8,11 skip 7 & 8, already done process 7 & 11 process 8 & 11

Sound about right? Or am I completely missing something that makes this harder than I'm thinking?

Aaron B.
My Woefully Neglected Blog, where I occasionally mention Perl.


In reply to Re: How to code this? by aaron_baugher
in thread How to code this? by BrowserUk

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.