Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: High Performance Game of Life

by tybalt89 (Monsignor)
on Nov 14, 2019 at 19:06 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11108693]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-04-25 10:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found