From bc1c88feeec88f3b0c9b3536ba2cce7d8ea1df1b Mon Sep 17 00:00:00 2001 From: "Jan \"Yenya\" Kasprzak" Date: Sun, 4 Dec 2022 06:11:25 +0100 Subject: [PATCH] Day 4: 2nd part too slow --- 2022/07.pl | 14 ++++++++++++++ 2022/08.pl | 16 ++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100755 2022/07.pl create mode 100755 2022/08.pl diff --git a/2022/07.pl b/2022/07.pl new file mode 100755 index 0000000..a0a237e --- /dev/null +++ b/2022/07.pl @@ -0,0 +1,14 @@ +#!/usr/bin/perl -w + +use v5.36; +use strict; +use experimental 'multidimensional'; + +my $count; +while (<>) { + my @r = /\d+/g; + $count++ if $r[0] <= $r[2] && $r[1] >= $r[3] + || $r[0] >= $r[2] && $r[1] <= $r[3]; +} +say $count; + diff --git a/2022/08.pl b/2022/08.pl new file mode 100755 index 0000000..c7f9131 --- /dev/null +++ b/2022/08.pl @@ -0,0 +1,16 @@ +#!/usr/bin/perl -w + +use v5.36; +use strict; +use experimental 'multidimensional'; + +my $count; +while (<>) { + my @r = /\d+/g; + $count++ if $r[0] <= $r[2] && $r[1] >= $r[3] + || $r[0] >= $r[2] && $r[1] <= $r[3] + || $r[0] <= $r[2] && $r[1] >= $r[2] + || $r[0] <= $r[3] && $r[1] >= $r[3]; +} +say $count; + -- 2.43.5