Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Fun, kinda silly, and doesn't actually work on your trial set. Failures happen around points with large deviations from the smoothed concept.
my @also = sort {$a->[0] <=> $b->[0]} @points; for my $i (reverse 0 .. $#points) { splice @also, $i, 1 if $points[$i] ne $also[$i]; }
More generally, I feel like there is a merge-sort-like solution in there somewhere, but can't quite seem to distill it in my brain. Not that it would be practical, since push-pop is already O(N), but that's not the point, right?

Streaming buffer w/ STDIN/STDOUT:

my $frame = 10; my @buffer; $, = ' '; $\ = "\n"; while (<>) { my @row = split; if (@buffer and ($buffer[-1][0] < $row[0]) ^ ($buffer[-1][1] < $ro +w[1]) ) { pop @buffer; } else { print @{shift @buffer} if $frame < push @buffer, \@row; } } print @$_ for @buffer
Note the ridiculous micro-optimization for comparison.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.


In reply to Re: How would you code this? by kennethk
in thread How would you code this? by BrowserUk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2024-04-23 10:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found