in reply to Re: compare values within a hash
in thread compare values within a hash

Gotcha! I appreciate everyone's help. These ideas are exactly what I am in need of.

The computer might be stupid, but I know just enough to convince it to really screw up. I have already accomplished the infinite loop!

I would like to collapse all overlaps into ONE line. I get what you are asking. If the min values are not within 10 but the max values are, then I would like those lines reduced to one representative.

Your second question is harder for me, I think. I want at least 10 units of separation between the max of one element and the min of the next. 10 is an arbitrary number, but again, its theory I am looking for, I think.

I always thought I was pretty bright and an abstract thinker, but you guys are in a completely different league. I have lurked for a long time. Whenever I needed to be humbled, I came here!

Replies are listed 'Best First'.
Re^3: compare values within a hash
by gwadej (Chaplain) on Oct 27, 2008 at 18:52 UTC

    I believe you are getting it. The key is that you need to understand what you want well enough to explain it to this stupid computer. As you get more practice, you will learn which requirements you really need to specify well and which you can slide on.

    Unfortunately, bright and abstract thinking are sort of independent of the way to think about this kind of problem. You almost have to look at it as if the computer is going to exploit anything you haven't specified well. The worst part is that sometimes an underspecified program will appear to work and lull you into a false sense of security.

    The answers you are getting are from people that have been bitten over and over again by times when they thought they knew what they were doing.

    Welcome to the wonderful world of programming!

    G. Wade
Re^3: compare values within a hash
by ig (Vicar) on Oct 27, 2008 at 19:44 UTC

    The following two statements about what you are trying to do seem very different to me.

    If the groups are the same, I would like to look at the first numerical value. If they are within 10 of each other, I would like to take the lesser value and then look at the second number. If they are within 10, I would like to take the greater value.
    I want at least 10 units of separation between the max of one element and the min of the next.

    If you have the following:

    group1 10 15 group1 22 50

    Do you want these to be merged because the "separation" between 15 and 22 is less than 10 or not merged because neither 10 and 22 nor 15 and 50 are within 10 of each other?