Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
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 having an uproarious good time at the Monastery: (5)
As of 2024-06-18 13:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.