--- /dev/null
+#!/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;
+
--- /dev/null
+#!/usr/bin/perl -w
+
+use v5.16;
+
+my %score_of = (
+ '(' => 1,
+ '[' => 2,
+ '{' => 3,
+ '<' => 4,
+);
+
+my @sums;
+while (<>) {
+ chomp;
+ my $sum = 0;
+ 1 while s/\(\)|\[\]|\{\}|\<\>//;
+ next if /[\)\]\}\>]/;
+ next if !length;
+ for my $c (reverse split //) {
+ $sum *= 5;
+ $sum += $score_of{$c};
+ }
+ push @sums, $sum;
+}
+
+@sums = sort { $a <=> $b } @sums;
+say $sums[@sums/2];
+