commit 89fb0e4d563de933d8944dad2381d544a7bcf1b1
parent e13810840718404f4a19fb0a28afd909dbe3bf75
Author: Samir Parikh <noreply@samirparikh.com>
Date: Thu, 23 Dec 2021 16:45:40 +0000
update comments
Diffstat:
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/day10-1.2.pl b/day10-1.2.pl
@@ -41,22 +41,22 @@ foreach my $line (@input) {
my @chunk;
say $line;
foreach my $symbol (split //, $line) {
-# if the symbol is an opening symbol, add it to the @chunk array
+ # if the symbol is an opening symbol, add it to the @chunk array
if ( $symbol =~ m/\[|\{|\(|\</ ) {
push @chunk => $symbol;
print "$symbol is an opener. ";
say "current chunk is @chunk";
}
-# if the symbol is a closing symbol...
+ # if the symbol is a closing symbol...
if ( $symbol =~ m/\]|\}|\)|\>/ ) {
say "$symbol is a closer";
-# ...check if the symbol is a closing symbol for the last opened one
+ # ...check if the symbol is a closing symbol for the last opened one
if ($closer_for{$symbol} eq $chunk[-1]) {
say "$symbol is a matching closer";
-# pop off last opening symbol from the @chunk array
+ # pop off last opening symbol from the @chunk array
pop @chunk;
say "current chunk is @chunk";
-# otherwise, report an error
+ # otherwise, report an error
} else {
say "Expected $opener_for{$chunk[-1]}, but found $symbol instead.";
$error_score += $error_score{$symbol};