in reply to Is Perl less compact than Ruby? (Kind of competition)

339.
map{push@L,@C+0;push@C,lc=~/./g}<>;sub p{$_=pop@n}sub w{push@n,@_}whil +e($n<@C){$_=$C[$n++];if(/h/){p;w$n[-1-abs];$_>0&&splice@n,-2-$_,1}if( +/n/){w 0;$b<0||w$b+7*p while($b=index"htaoinse",$C[$n++])<7}$0=p,p,w +int$_/$0,$_%$0if/e/;if(/t/){$a=p;$a?$n=$L[$a-1]:last if p}/a/?w 1+gre +p$n>$_,@L:/o/?print chr p:/s/?w-(p)+p:/i/&&w+($_=getc)?ord:-1}
The big change was sub p{$_=pop@n} and the subsequent fall-out. *pants*\

Update: To 336...

if(/t/){$a=r;$a?$n=$L[$a-1]:last if r} --- $a=r,r&&($a?$n=$L[$a-1]:last)if/t/;

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Replies are listed 'Best First'.
29 characters to beat Ruby ...
by dragonchild (Archbishop) on Feb 19, 2002 at 18:39 UTC
    Another update, bringing to 331. Though I'm not sure the change is legal, it runs the Tic-Tac-Toe program.
    map{push@L,push@C,lc=~/./g}<>;sub p{$_=pop@n}sub w{push@n,@_}while($n< +@C){$_=$C[$n++];if(/h/){p;w$n[-1-abs];$_>0&&splice@n,-2-$_,1}if(/n/){ +w 0;$b<0||w$b+7*p while($b=index"htaoinse",$C[$n++])<7}$0=p,p,w int$_ +/$0,$_%$0if/e/;$a=p,p&&($a?$n=$L[$a-2]:last)if/t/;/a/?w 2+grep$n>$_,@ +L:/o/?print chr p:/s/?w-(p)+p:/i/&&w+($_=getc)?ord:-1}
    The change was to functionally remove the 0 at the beginning of @L. Adjusting the subscripts used to access @L seems to result in an acceptable performance.

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

      One thing people often forget is that push@L,values is a semantically equivalent (modulo being faster) to @L=@L,values - a saving of one character per push, or three characters in the above, bringing you down to 328.
        I tried @L=@L,push@C,lc=~/./g and it didn't work. I don't know enough of the language to be able to say why, but it didn't.

        This could only apply to the first push because I need the return value of the second push to be the value of the @L. Remember, @L is recording the byte that starts each line. @C is the list of bytes.

        In addition, map{push@L,push@C,lc=~/./g}for 0,<>; also didn't work. It puts 1 as the first element of @L, and 0 as the first element of @C. *shrugs*

        However, we can add a character, going back up to 327, and get it right:

        @L=(0,map{push@C,lc=~/./g}<>}; ---- Results in ---- @L=(0,map{push@C,lc=~/./g}<>};sub p{$_=pop@n}sub w{push@n,@_}while($n< +@C){$_=$C[$n++];if(/h/){p;w$n[-1-abs];$_>0&&splice@n,-2-$_,1}if(/n/){ +w 0;$b<0||w$b+7*p while($b=index"htaoinse",$C[$n++])<7}$0=p,p,w int$_ +/$0,$_%$0if/e/;$a=p,p&&($a?$n=$L[$a-1]:last)if/t/;/a/?w 1+grep$n>$_,@ +L:/o/?print chr p:/s/?w-(p)+p:/i/&&w ord getc||-1}

        Update: Make that 326 again.

        @L=(0,map{push@C,lc=~/./g}<>};sub p{$_=pop@n}sub w{push@n,@_}while($n< +@C){$_=$C[$n++];r,w($n[-1-abs]),$_>0&&splice@n,-2-$_,1if/h/;if(/n/){w + 0;$b<0||w$b+7*p while($b=index"htaoinse",$C[$n++])<7}$0=p,p,w int$_/ +$0,$_%$0if/e/;$a=p,p&&($a?$n=$L[$a-1]:last)if/t/;/a/?w 1+grep$n>$_,@L +:/o/?print chr p:/s/?w-(p)+p:/i/&&w ord getc||-1}

        ------
        We are the carpenters and bricklayers of the Information Age.

        Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

        Received! Only two bytes because first push now counts number of elements in @C not pushes elements itself.

        @a1=@a2,@a3 doesn't work :( parentheses needed

      Excellent tweak with push!

      map{push@L,push@C,lc=~/./g}0,<>; should fix this. It's nice question but I believe impossibility to jump on first line is some violation of language. It's my fault of incorrect target setting.

Superb dragonchild!
by locked_user mtve (Deacon) on Feb 19, 2002 at 18:37 UTC

    confirmed. i can't believe it! 336 bytes.

    only 16 bytes to make it four-liner.