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";
-15 23:19:00 -0400'>2019-05-15Support simple assignment in orderJune McEnroe 2019-05-15Implement sizeof in orderJune McEnroe 2019-05-15Add orderJune McEnroe 2019-05-12Add T suffix in bitJune McEnroe 2019-05-10Highlight yacc and lex files as CJune McEnroe 2019-05-10Use val instead of suboptargJune McEnroe 2019-05-09Add Parable of the SowerJune McEnroe 2019-05-07Add bit without buildJune McEnroe 2019-05-04Fix MANDIR typoJune McEnroe 2019-05-04Move relay to binJune McEnroe