From 2a57f4ea5de34b5edd8c12929c917441288be853 Mon Sep 17 00:00:00 2001 From: "Jan \"Yenya\" Kasprzak" Date: Fri, 2 Dec 2022 06:22:18 +0100 Subject: [PATCH] Day 2: in English it is in a different order than in Czech! --- 2022/03.pl | 24 ++++++++++++++++++++++++ 2022/04.pl | 27 +++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100755 2022/03.pl create mode 100755 2022/04.pl diff --git a/2022/03.pl b/2022/03.pl new file mode 100755 index 0000000..1d929ac --- /dev/null +++ b/2022/03.pl @@ -0,0 +1,24 @@ +#!/usr/bin/perl -w + +use v5.36; +use strict; +use experimental 'multidimensional'; + +my $sum; +while (<>) { + chomp; + $sum += 1 if /X/; + $sum += 2 if /Y/; + $sum += 3 if /Z/; + + $sum += 3 if /A X/; + $sum += 3 if /B Y/; + $sum += 3 if /C Z/; + + $sum += 6 if /A Y/; + $sum += 6 if /B Z/; + $sum += 6 if /C X/; +} + +say $sum; + diff --git a/2022/04.pl b/2022/04.pl new file mode 100755 index 0000000..4d5ebfd --- /dev/null +++ b/2022/04.pl @@ -0,0 +1,27 @@ +#!/usr/bin/perl -w + +use v5.36; +use strict; +use experimental 'multidimensional'; + +my $sum; +while (<>) { + chomp; + $sum += 3 if /Y/; + $sum += 6 if /Z/; + + $sum += 3 if /A X/; + $sum += 1 if /A Y/; + $sum += 2 if /A Z/; + + $sum += 1 if /B X/; + $sum += 2 if /B Y/; + $sum += 3 if /B Z/; + + $sum += 2 if /C X/; + $sum += 3 if /C Y/; + $sum += 1 if /C Z/; +} + +say $sum; + -- 2.43.0