http://qs321.pair.com?node_id=11108693


in reply to High Performance Game of Life

... I'm interested to see how others go about it.
Here's one. It's not fast, but it makes up for it with cuteness :)

#!/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; }