summary refs log tree commit diff homepage
path: root/2021/day01.pl
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";
tr> 2020-12-15Update pounce to 2.1p1June McEnroe 2020-12-15Add imbox portJune McEnroe 2020-11-24Update pounce to 2.1June McEnroe 2020-11-24Update libretls to 3.3.0June McEnroe 2020-11-17Update catgirl to 1.3June McEnroe 2020-11-17Update libretls to 3.2.2June McEnroe 2020-09-29Update libretls to 3.2.1June McEnroe 2020-09-10Update catgirl to 1.2June McEnroe 2020-09-09Add pounce-palaver portJune McEnroe 2020-09-09Update pounce to 2.0June McEnroe 2020-09-09Update litterbox to 1.6June McEnroe 2020-08-23Add scooper portJune McEnroe 2020-08-23Add catsit portJune McEnroe 2020-08-13Update pounce to 1.4p2June McEnroe 2020-08-11Update pounce to 1.4p1June McEnroe 2020-08-10Add litterbox portJune McEnroe 2020-08-10Add missing USES=pkgconfig to pounceJune McEnroe