in reply to last version
in thread Is Perl less compact than Ruby? (Kind of competition)
map{push@L,@C+0;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;/ +-/||w$_+7 *p while($_=index"htaoinse",$C[$n++])<7}$0=p,$_=p,w int$_/$0,$_%$0if/e +/;if(/t/) {$_=p;$_?$n=$L[$_-1]:last if p}/a/?w 1+grep$n>$_,@L:/o/?print chr p:/s +/?w-(p)+p :/i/&&w($_=getc)?ord:-1}
map{push@L,@C+0;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;/ +-/||w$_+7 *p while($_=index"htaoinse",$C[$n++])<7}$0=p,$_=p,w int$_/$0,$_%$0if/e +/;if(/t/) {$_=p;$_?$n=$L[$_-1]:p&&last}/a/?w 1+grep$n>$_,@L:/o/?print chr p:/s/? +w-(p)+p: /i/&&w($_=getc)?ord:-1}
map{push@L,@C+0;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;/ +-/||w$_+7 *p while($_=index"htaoinse",$C[$n++])<7}w int($_=p)/($0=p),$_%$0if/e/; +if(/t/) {$_=p;$_?$n=$L[$_-1]:p&&last}/a/?w 1+grep$n>$_,@L:/o/?print chr p:/s/? +w-(p)+p: /i/&&w($_=getc)?ord:-1}
A ternary operator can be replaced by a && and the plus in w+($_=getc)?ord:-1 trick is not needed, it works without (or, at least, hello.eta still outputs correctly).
I have an idea it must be possible to replace the w$_+7*p while($_=index"htaoinse",$C[$n++])<7 section with a redo and/or a pos, but it is so difficult to understand what the program does I am beginning to wonder whether it wouldn't be easier to look at the instruction set and come up with another angle of attack. For instance, it would be nice to be able to do away with the @L array as well. Replace @C and @L by a hash that is keyed on byte offset and the value is the byte.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
1 byte
by locked_user mtve (Deacon) on Feb 19, 2002 at 14:19 UTC |