Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Sorting the numbers: A little tricky.

by choroba (Canon)
on Jan 25, 2013 at 21:46 UTC ( #1015414=note: print w/ replies, xml ) Need Help??


in reply to Sorting the numbers: A little tricky.

I am still not sure I understand your specification. You should test this code with more data to see whether it behaves well in all the border cases:

#!/usr/bin/perl use warnings; use strict; my ($first, $last, $last_small) = ('0e0', 0, 0); while (<DATA>) { my ($big, $small) = split; next if 4 >= $small; if ($big > $first + 50) { show($first, $last, $last_small); $first = $big; } $last = $big; $last_small = $small; } show($first, $last, $last_small); sub show { my ($first, $last, $last_small) = @_; print "$first ", $last + 50, " $last_small\n" unless '0e0' eq $fir +st; } __DATA__ 109026 3 109027 28 109028 30 116958 15 116960 35 116961 39 116962 70 116963 72 147184 2 147588 1 153087 32
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ


Comment on Re: Sorting the numbers: A little tricky.
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1015414]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2015-07-04 17:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls