]> www.fi.muni.cz Git - aoc.git/blobdiff - 2021/19.pl
Moved 2021 to a subdir
[aoc.git] / 2021 / 19.pl
diff --git a/2021/19.pl b/2021/19.pl
new file mode 100755 (executable)
index 0000000..419030b
--- /dev/null
@@ -0,0 +1,22 @@
+#!/usr/bin/perl -w
+
+use v5.16;
+
+my %score_of = (
+       ')' => 3,
+       ']' => 57,
+       '}' => 1197,
+       '>' => 25137,
+);
+
+my $sum;
+while (<>) {
+       chomp;
+       1 while s/\(\)|\[\]|\{\}|\<\>//;
+       s/^[\(\[\{\<]*//;
+       next if !length;
+       $sum += $score_of{substr($_, 0,1)};
+}
+
+say $sum;
+