From e248e4355dd8002b8ea6cfa5b9ada19a32676110 Mon Sep 17 00:00:00 2001 From: "Jan \"Yenya\" Kasprzak" Date: Wed, 1 Dec 2021 06:11:09 +0100 Subject: [PATCH] Day 1. Got 504 gateway timeout :( --- 01.pl | 14 ++++++++++++++ 02.pl | 15 +++++++++++++++ 2 files changed, 29 insertions(+) create mode 100755 01.pl create mode 100755 02.pl diff --git a/01.pl b/01.pl new file mode 100755 index 0000000..f1912b2 --- /dev/null +++ b/01.pl @@ -0,0 +1,14 @@ +#!/usr/bin/perl -w + +use strict; + +my $prev; +my $inc; +while (<>) { + chomp; + $inc++ if $prev && $_ > $prev; + $prev = $_; +} + +print $inc, "\n"; + diff --git a/02.pl b/02.pl new file mode 100755 index 0000000..b9fbfb5 --- /dev/null +++ b/02.pl @@ -0,0 +1,15 @@ +#!/usr/bin/perl -w + +use strict; + +chomp (my @a = <>); +my $prev; +my $inc; + +for my $i (0 .. $#a-2) { + my $sum = $a[$i]+$a[$i+1]+$a[$i+2]; + $inc++ if $prev && $sum > $prev; + $prev = $sum; +} + +print "$inc\n"; -- 2.43.5