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";
s.c?id=3dd2cbde032f02fce7fab4bba03405bd9a289314&follow=1'>Avoid matching ':' in make tagsJune McEnroe 2021-01-19Prefer tag matches not preceded by [[:alnum:]]June McEnroe 2021-01-19Escape \ and / in mtags search patternsJune McEnroe 2021-01-20Use mtags in source-filterJune McEnroe 2021-01-19Add mtags to generate tags for make and mdocJune McEnroe 2021-01-19Map tags to IDs using only [[:alnum:]-._]June McEnroe 2021-01-19Don't use a pager if reading standard inputJune McEnroe 2021-01-19Support BSD make syntax and match *.amJune McEnroe 2021-01-19Match tab following escaped newline in make assignmentsJune McEnroe 2021-01-18Allow matching lexers using first input lineJune McEnroe