-print join("\n", $shortmap), "\n";
-
-my $monster = join('[\.#\n]' x ($dim * 8 - 20 + 1), map { $a=$_; $a=~ s/\./[\.#]/g; $a }
- '..................#.',
- '#....##....##....###',
- '.#..#..#..#..#..#...'
-);
-
-$monster = ".(?=$monster)";
-print "monster=$monster\n";
-
-for (1 .. 2) {
- for (1 .. 4) {
- my $count;
- if (my $count =()= $shortmap =~ /($monster)/g) {
- print "$count matches\n";
- my $hashes =()= $shortmap =~ /#/g;
- print "$hashes-$count*15=", $hashes-$count*15, "\n";
- exit 0;
- }
- my $newmap = '';
- for my $y (0 .. 8*$dim-1) {
- for my $x (0 .. 8*$dim-1) {
- print "$x,$y\n";
- $newmap .= substr($shortmap,
- $y + (8*$dim+1)*(8*$dim-$x-1), 1);
- }
- $newmap .= "\n";
- }
- print "\nRotate:\n$newmap\n";
- $shortmap = $newmap;
- }
- my $newmap;
- for my $y (0 .. 8*$dim-1) {
- for my $x (0 .. 8*$dim-1) {
- $newmap .= substr($shortmap,
- $x + (8*$dim+1)*(8*$dim-$y-1), 1);
- }
- $newmap .= "\n";
+my $map = rows2str(@map_rows);
+my $hashes =()= $map =~ /#/g;
+
+my $monster = '.(?='
+ . join('[\.#\n]' x ($dim * 8 - 20 + 1),
+ map { my $a=$_; $a=~ s/\./[\.#]/g; $a }
+ '..................#.',
+ '#....##....##....###',
+ '.#..#..#..#..#..#...'
+ ) . ')';
+
+for (1 .. 8) {
+ if (my $count =()= $map =~ /($monster)/g) {
+ print "$count matches\n";
+ print "$hashes-$count*15=", $hashes-$count*15, "\n";
+ exit 0;