Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-16 06:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found