adventofcode/2015/01/d1b.pl

11 lines
162 B
Perl
Raw Normal View History

2017-12-03 21:25:02 +00:00
use 5.20.0;
use List::AllUtils qw/ reduce /;
my $i;
reduce {
my $l = $a + ( $b eq '(' ? 1 : -1 );
$i++;
die $i if $l < 0;
$l;
} 0, split '', <>;