Christmas Lights = keeping a terminal alive with a CA
l3v3l
created: 2005-12-24 17:58:43
Merry Christmas Monks!!!
perl -e 'for(1..40){push(@a1,($_==20? "^" : " "))};$l=@a1;while(1){@a2="";print "@a2\n@a1\n";for(0..($l-1)){$a2[$_] = ($a1[$_] eq " " ? ($a1[$_-1] eq "^"? "^" : ($a1[$_+1] eq "^" ? "^" : " ")) : ($a1[$_-1] eq " " ? "^" : ($a1[$_+1] eq " " ? "^" : " ")))}qx(sleep 1);@a1=@a2;}'
Re: Christmas Lights = keeping a terminal alive with a CA
created: 2005-12-27 07:50:56

Running this, I see that this is a typical "XOR-like" cellular automata, but a quick glance at the code, without any serious attempt to dissect it in detail, reveals that you're doing all the heavylifting yourself, whereas you may have perl do it for you courtesy of bitwise operators acting on strings. Here follows a minimal example exploiting them. It does something similar to yours. Of course it's left as an exercise to you to suitably golf/obfuscate it if you like. I used a similar technique in [id://410408].

#!/usr/bin/perl -l

use strict;
use warnings;

my $len=80;
my $line = '!' x $len;
substr +($line ^= $line), $len/2, 1, "\xFF";

{
    local $_=$line;
    y/\0\xFF/ ^/;
    print;
    my ($lf, $rt) = map {
        substr $line x 2, $_ % $len, $len;
    } 1, -1;
    $line=$lf ^ $rt;
    select undef, undef, undef, .1;
    redo;
}

__END__
Re: Christmas Lights = keeping a terminal alive with a CA
created: 2005-12-28 11:05:55

Oh God!!! Sierpinski Triangle in a perlish flavoured ASCII Art!!!!
Wow, i'm really impressed!!

turo

PS: umm, ... i'm wondering, why didnt' you post this code-opera at 'Obfuscation' or 'Poetry' or 'Perl Hacks :-P' ... anyway ... it's really cool :-)

perl -Te 'print map { chr((ord)-((10,20,2,7)[$i++])) } split //,"turo"'

perlmonks.org content © perlmonks.org and blazar, l3v3l, turo

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03