in reply to Re: Life!
in thread Life!

you mean, something like this? :)
use Storable 'dclone';for$y(0..23){$l[$_][$y]=int(rand 7)?0:1for(0..79 +)}while(1){@f=@{dclone\@l};print"\033[2J";for$y(0..23){for$x(0..79){p +rint$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}

cLive ;-)

Replies are listed 'Best First'.
Re: Life! (golf)
by jonadab (Parson) on Mar 21, 2004 at 00:59 UTC

    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