note
tybalt89
<p>
<blockquote><i>... I'm interested to see how others go about it. </i></blockquote>
Here's one. It's not fast, but it makes up for it with cuteness :)
</p>
<c>
#!/usr/bin/perl
print $_ = <<'' =~ tr/./ /r; # test case, dots only for layout
...........
.......#...
........#..
.###..###..
...........
...........
my $gap = /..\n/ ? qr/.{$-[0]}/s : die "too small";
my $neighborhood = qr/(?<=(...) $gap (.)) . (?=(.) $gap (...))/x;
for my $generation ( 2 .. 5 )
{
s/$neighborhood/ substr " $&# ", "$1$2$3$4" =~ tr|#||, 1 /ge;
print;
}
</c>
1197250
1197250