aoc2021

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

commit 9e04b14633f111fba29d08216bbe54fef87f1b77
parent d4c8dc1a4a43d0c8e5a8cefcf7216f904dc1ba52
Author: Samir Parikh <noreply@samirparikh.com>
Date:   Wed,  1 Dec 2021 21:27:34 +0000

add Day 01 Part 1 solution

Diffstat:
Aday01-1.pl | 16++++++++++++++++
1 file changed, 16 insertions(+), 0 deletions(-)

diff --git a/day01-1.pl b/day01-1.pl @@ -0,0 +1,16 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use v5.22; + +if (@ARGV !=1) { + die "Usage: $0 [input-filename]"; +} + +my $input_filename = $ARGV[0]; +open my $filehandle, '<', $input_filename or + die "Could not open input file $input_filename: $!"; + +chomp( my @input = ( <$filehandle> ) ); +say scalar( grep { $input[$_] > $input[$_ - 1] } (1 .. $#input) );