adventofcode/2015/19/1.pl
Yanick Champoux 2b88e2660e lots of days
2017-12-12 19:55:17 -05:00

23 lines
321 B
Perl

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;