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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |