]> www.fi.muni.cz Git - aoc.git/commitdiff
Day 4: 2nd part too slow
authorJan "Yenya" Kasprzak <kas@fi.muni.cz>
Sun, 4 Dec 2022 05:11:25 +0000 (06:11 +0100)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Sun, 4 Dec 2022 05:11:25 +0000 (06:11 +0100)
2022/07.pl [new file with mode: 0755]
2022/08.pl [new file with mode: 0755]

diff --git a/2022/07.pl b/2022/07.pl
new file mode 100755 (executable)
index 0000000..a0a237e
--- /dev/null
@@ -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 (executable)
index 0000000..c7f9131
--- /dev/null
@@ -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;
+