aoc2021

Advent of Code 2021 solutions in Perl.
git clone git://git.samirparikh.com/aoc2021
Log | Files | Refs | README

commit 9f929507996da7d9f63427f9f5f2c4a0cb213d54
parent e02622e3ac6a9f7e5224efef7bd6f66a89f8e35b
Author: Samir Parikh <noreply@samirparikh.com>
Date:   Wed,  1 Dec 2021 22:07:53 +0000

update Day 01 solution to remove unnecessary lines
as we do not need to compute the "overlap" as it is present
in both windows

Diffstat:
Mday01.pl | 9+--------
1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/day01.pl b/day01.pl @@ -19,11 +19,4 @@ chomp( my @input = ( <$filehandle> ) ); say scalar( grep { $input[$_] > $input[$_ - 1] } (1 .. $#input) ); # Part 2 -say scalar( - grep { - my $overlap = $input[$_] + $input[$_ + 1]; - my $first_window = $overlap + $input[$_ - 1]; - my $second_window = $overlap + $input[$_ + 2]; - $second_window > $first_window - } (1 .. $#input - 2) -); +say scalar( grep { $input[$_ + 2] > $input[$_ - 1] } (1 .. $#input - 2) );