aoc2021

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

day01-1.pl (358B) - raw


      1 #!/usr/bin/env perl
      2 
      3 use strict;
      4 use warnings;
      5 use v5.22;
      6 
      7 if (@ARGV !=1) {
      8     die "Usage: $0 [input-filename]";
      9 }
     10 
     11 my $input_filename = $ARGV[0];
     12 open my $filehandle, '<', $input_filename or
     13     die "Could not open input file $input_filename: $!";
     14 
     15 chomp( my @input = ( <$filehandle> ) );
     16 say scalar( grep { $input[$_] > $input[$_ - 1] } (1 .. $#input) );