6 chomp (my $state = <>);
14 my ($src, $dst) = split / => /;
20 if ($state !~ /^\.\.\.\./) {
21 $state = '....' . $state;
25 $state = $state . '....' if $state !~ /\.\.\.\.$/;
30 for my $p (2 .. length($state)-3) {
31 my $src = substr($state, $p-2, 5);
32 # die "no rule for $src" if !exists $rules{$src};
33 substr($nstate, $p, 1) = $rules{$src} if defined $rules{$src};
40 while ($state =~ /#/g) {
41 say "at ", pos($state) + $off - 1;
42 $sum += pos($state) + $off - 1;