in reply to Re: Re: Life! (golf)
in thread Life!

Yeah, something like that. I managed to save another dozen strokes, though...

use Storable 'dclone';@l=map{[map{int rand 7?0:1}0..23]}0..79;while(1){@f=@{dclone\@l};print"\033[2J";for$y(0..23){for$x(0..79){print$l[$x][$y]?O:$";$n=0;for$h(-1..1){!$_&&!$h or$n+=$l[($x+$_)%79][($y+$h)%23]for-1..1}$l[$x][$y]?$n<2||$n>3?$f[$x][$y]=0:0:$n==3?$f[$x][$y]=1:0}print$/}@l=@{dclone\@f};sleep 1}

It's probably possible to do still better by devious means, but that's as short as I can make it without changing the logic. I'm not really a golf pro.


;$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$;[-1]->();print