in reply to compare values within a hash

What happens if you have:
group1 10 20 group1 18 22 group1 25 21
When looking at the first numbers, 10 and 18 are less than 10 apart, 18 and 25 are less than 10 apart, but 10 and 25 aren't. Do you want to keep the 10 (because it's the lesser of 10 and 18). Do you want to keep the 18? (because it's the lesser of 18 and 25). Keep them both? Is the 25 discarded? And if I have
group1 10 20 group1 15 25
What is the result?
group1 10 25
that is, take the lesser of (10, 15) and the greater of (20, 25)?

Finally, what if I have:

group1 10 15 group1 15 50
The first numeral values are less than 10 apart, so you keep the 10. But 15 and 50 are more than 10 apart. What's the result?

Replies are listed 'Best First'.
Re^2: compare values within a hash
by rookierabbit (Initiate) on Oct 27, 2008 at 17:32 UTC

    Thanks Java
    I didn't realize how vague I was until I read it again. The file is sorted lexically. Also, in all cases, the lesser of the two numbers is in the first column. I basically am trying to say that foreach same group, are the numbers in the first column within 10 of each other. If yes, are the numbers in the second column ALSO within 10 of each other.

    Your example would give me.

    group1 10 25

    This assumes that the last row would actually be

    group1 21 25

    But they idea is to collapse all three lines into one. I am looking for a "window" or frame that would essentially include all of the overlapping lines collapsed into one. Eventually, I will use the single lines in downstream applications.

    You folks are fantastic. I work with people that are great programmers, not so great at explaining why I need to do why they say!

      When I am interviewing programmers, one of the defining differences between a senior developer and an intermediate developer is the ability to explain what they are doing. I normally expect seniors to be able to mentor more junior people.

      G. Wade