Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: High Performance Game of Life

by tybalt89 (Prior)
on Nov 14, 2019 at 19:06 UTC ( #11108693=note: print w/replies, xml ) Need Help??


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; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11108693]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2020-12-05 02:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you use taint mode?





    Results (63 votes). Check out past polls.

    Notices?