in reply to Is Perl less compact than Ruby? (Kind of competition)
Thanks to tadman, cLive ;-) , blakem, dragonchild, grinder, Matts, jynx and PerlMonks.org, Perl version in now
officially 333 bytes (or 327 bytes with some cheating), while Ruby is still 306 bytes.
map{push@L,push@C,lc=~/./g}0,<>;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+($_ =getc)?ord:-1}
| Replies are listed 'Best First'. | |
|---|---|
|
Completely different algorithm
by locked_user mtve (Deacon) on Feb 20, 2002 at 15:18 UTC | |
by japhy (Canon) on Feb 20, 2002 at 19:51 UTC | |
by locked_user mtve (Deacon) on Feb 20, 2002 at 21:13 UTC | |
by japhy (Canon) on Feb 20, 2002 at 21:40 UTC | |
by Matts (Deacon) on Feb 21, 2002 at 08:08 UTC | |
| |
by japhy (Canon) on Feb 20, 2002 at 21:19 UTC | |
by locked_user mtve (Deacon) on Feb 20, 2002 at 21:27 UTC | |
| |
by dragonchild (Archbishop) on Feb 20, 2002 at 17:58 UTC | |
by locked_user mtve (Deacon) on Feb 20, 2002 at 19:14 UTC |