Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Sorting the numbers: A little tricky.

by oxydeepu (Novice)
on Jan 28, 2013 at 09:39 UTC ( #1015659=note: print w/replies, xml ) Need Help??

in reply to Sorting the numbers: A little tricky.

Hi all,
I will try and explain it the last time. So the file have two columns first is postion and second column is the cumulative frequencies within 50 numbers of the postions.

for ex,

109026 3
109027 25
109028 2


109026 3
109027 28
109028 30.

So what I have to do is iterate through the postions, which is column 1, get the postions which go increasing and till there is a difference between the current postion and (latter postion + 50) becomes > 50.

for example

109027 28
109028 30
116958 15
116960 35
116961 39
116962 70
116963 72
153087 32

in the above set,
i will start with 109027, then 109028 and then 116958. Here 116958 - (109028 + 50) is greater than 50
so the first line in the output will be

109027 109078 (which is 109028 + 50) 30

the 30 is the value of position 109028.

next step i have to start from 116958 go through 116963 till 153087, since the difference 153087 - (116963 + 50 ) becomes > 50
So i will stop the iteration and output the next line, which is

116958 117013 (which is 116963 + 50) 72

where 72 is the value for 116963

then i will start from 153087, since there no increasing. I have to stop the iteration and out like this

153087 153137 (which is 153087 + 50) 32

This is the problem. I don't know whether i explained it better than last time. I don't have a code, i'm still stuck with how to implement. Hoping for help.

Thank you in advance.

  • Comment on Re: Sorting the numbers: A little tricky.

Replies are listed 'Best First'.
Re^2: Sorting the numbers: A little tricky.
by choroba (Bishop) on Jan 28, 2013 at 09:55 UTC
    As far as I understand, that is what my code here does.
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1015659]
[1nickt]: Corion I am trying to keep an open mind :-) Or at least, go with the flow. marto yes I saw som photos of lorries overturned on country roads, and wondered why they would have been driving fast enough to have that happen!

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2017-12-11 11:58 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (289 votes). Check out past polls.