adventofcode/2015/19/1.pl

23 lines
321 B
Perl
Raw Normal View History

2017-12-13 00:55:17 +00:00
use 5.20.0;
my @lines = <>;
chomp for @lines;
my $sequence = pop @lines;
pop @lines;
my %molecules;
for my $s ( @lines ) {
my( $from, $to ) = split ' => ', $s;
while( $sequence =~ /\G(.*?)($from)/g ) {
$molecules{
$` . $1 . $to . $'
} = 1;
}
}
say scalar keys %molecules;