blob: ffc594977b372ac6d4be6ad4b4bd9a17185bbe42 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
use strict;
use warnings;
my ($last, @window, $incs, $incs2);
while (<>) {
$incs++ if ($last && $_ > $last);
$last = $_;
if (scalar @window == 3) {
my $prev = $window[0] + $window[1] + $window[2];
my $next = $window[1] + $window[2] + $_;
$incs2++ if ($next > $prev);
shift @window;
}
push @window, $_;
}
print "$incs\n$incs2\n";
|