]> www.fi.muni.cz Git - aoc2021.git/blobdiff - 07.pl
Day 25: pretty straightforward
[aoc2021.git] / 07.pl
diff --git a/07.pl b/07.pl
index c304d7cbc3a91a1bcdf5fd302f5bc43485a2fc08..d41536ae8c095f94b250bd4880e712488a014051 100755 (executable)
--- a/07.pl
+++ b/07.pl
@@ -2,23 +2,17 @@
 
 use v5.16;
 
-my @drawn = split/[,\s]/, scalar <>;
-scalar <>;
-
 $/ = "\n\n";
 
+my @drawn = split/[,\s]/, <>;
 my @boards = <>;
 
-say $boards[0];
-
 for my $d (@drawn) {
        for my $board (@boards) {
                $board =~ s/\b$d\b/' ' x length $d/e;
-               if ($board =~ /              /
-                       || $board =~ /\s{3}.{12}\s{3}.{12}\s{3}.{12}\s{3}.{12}\s{3}/xms) {
-                       say $board;
+               if ($board =~ / {14}/
+                       || $board =~ /\s{3}(?:.{12}\s{3}){4}/xms) {
                        $board =~ s/(?<=\d)\s+(?=\d)/+/gxms;
-                       say "$board";
                        say eval "$d*($board)";
                        exit;
                }