Postorder Post Mortem Back to Perl Golf

Accepted | Artistic/Unorthodox | Rejected

Referee comments are in italics. Blue rows denote golfer's best solution. Red text denotes special characters.

Accepted

ScoreGolferSubmit TimeCode
49.09 Stephen Turner Sun Aug 4 13:33:21 2002
s~~
@ARGV~;print$1until!s~(.)(?= |(.).+\2.*\1)~~s
Whoops, I was so busy optimising the main regexp that I didn't notice I had s/// instead of s~~~ at the beginning! Tildes are your friends.
49.09 Stephen Turner Sun Aug 4 14:19:59 2002
s~~
@ARGV~;print$1until!s~(.)( |(.).+\3.*\1)~\2~s
This one has even better tie-breaker, in the 3rd decimal place.

Ah, \2 instead of $2 in the replacement. That indeed wins. You are now strictly the leader on postorder

49.09 Rick Klement Sat Aug 3 00:39:15 2002
s~~
@ARGV~;print$1until!s~(.)(?=(.).*\2.*\1| )~~s
49.09 Rick Klement Sun Aug 4 22:18:35 2002
s~~
@ARGV~;print$1until!s~(.)((.).+\3.*\1| )~\2~s
The \2 in the replacement is bad perl, but a better golf tiebreaker :)
49.09 Eugene van der Pijll Fri Aug 2 21:11:02 2002
s~~
@ARGV~;print$1until!s~(.)(?=(.).*\2.*\1| )~~s
Ha!
49.09 Eugene van der Pijll Tue Aug 6 17:14:37 2002
s~~
@ARGV~;print$1until!s~(.)((.).+\3.*\1| )~\2~s
Improved tiebreaker (0.0024)
49.09 BoB (Best of Breed - referees) Fri Aug 2 21:19:35 2002
s~~
@ARGV~;print$1until!s~(.)(?=(.).*\2.*\1| )~~s
49.11 Stephen Turner Sun Aug 4 12:14:46 2002
s//
@ARGV/;print$1until!s~(.)( |(.).+\3.*\1)~$2~s
I never imagined when reading the problems that I could get the same score on postorder as on factorial.

that's because your factorial is so long

49.11 Stephen Turner Sun Aug 4 13:06:24 2002
s//
@ARGV/;print$1until!s~(.)(?= |(.).+\2.*\1)~~s
Fractionally better tiebreaker. Yes, I know it doesn't even change my official score. But that's the problem with tiebreakers to 4 d.p.!
50.08 Wladimir Palant Thu Aug 1 18:33:56 2002
-l for$}(pop,pop=~/./g){s~$}(.*)|$~
$1
$}~}print//
50.10 Eugene van der Pijll Fri Aug 2 20:42:29 2002
s~~@ARGV
~;print$&until!s~(.)(?=(.).*\2.*\1| )|
~~
50.10 BoB (Best of Breed - referees) Thu Aug 1 11:34:52 2002
-l for$~(pop,pop=~/./g){s/$~(.*)|$/
$1
$~/}print//
50.10 Wladimir Palant Thu Aug 1 18:23:27 2002
-l for$~(pop,pop=~/./g){s/$~(.*)|$/
$1
$~/}print//
50.12 Rick Klement Fri Aug 2 23:50:13 2002
$_="
@ARGV";print$1while+s~(.)(?=(.).*\2.*\1| )~~s
51.08 Juho Snellman Thu Aug 8 04:27:42 2002
-l $_=pop;for$~(pop=~?.?g){s|$~(.*)|
$1
$~|}print??
Forgot another //
51.09 Juho Snellman Mon Aug 5 15:58:10 2002
-l $_=pop;for$~(pop=~/./g){s|$~(.*)|
$1
$~|}print//
Huh? Why isn't the /g needed in the last regexp? Well, it passes the tests, so it must be correct... :-)
51.09 Juho Snellman Thu Aug 8 04:26:14 2002
-l $_=pop;for$~(pop=~?.?g){s|$~(.*)|
$1
$~|}print//
// - ?? for tiebreaker
51.10 Chris Dolan Mon Aug 5 23:22:20 2002
-l @ARGV[$_=pop]=~s^.^s~($&)(.*)~
$2
$1~^ge|print//
Trial and error pays off unexpectedly
51.10 tinita Mon Aug 5 09:19:48 2002
-l $ARGV[$_=pop]=~s|.|s~($&)(.*)~
$2
$1~|eg;print//
using perl's magical //
51.10 tinita Wed Aug 7 18:40:25 2002
-l $ARGV[$_=pop]=~s}.}s~($&)(.*)~
$2
$1~}eg;print//
51.10 Markus Laire Thu Aug 8 03:23:33 2002
-l $_=pop;for$~(pop=~/./g){s/$~(.*)/
$1
$~/}print//
51.16 Eugene van der Pijll Fri Aug 2 20:28:55 2002
$_="@ARGV
";print$&while s/(.)(?=(.).*\2.*\1| )|
//
I'm getting closer...
52.08 Wladimir Palant Thu Aug 1 11:32:50 2002
-l for$~(pop,pop=~/\w/g){s/$~(\w*)|$/ $1 $~/}print//
52.09 Juho Snellman Mon Aug 5 14:50:22 2002
-l $_=pop;for$~(pop=~/./g){s|$~(.*)|
$1
$~|}print//g
Doh! \w -> .
52.10 Chris Dolan Mon Aug 5 23:17:00 2002
-l $ARGV[$_=pop]=~s^.^s~($&)(.*)~
$2
$1~^ge|print//g
Ahh, the empty regex. We'll miss you...
52.10 tinita Mon Aug 5 01:05:52 2002
-l $ARGV[$_=pop]=~s|.|s~($&)(.*)~
$2
$1~|eg;print//g
I actually don't know why "$ARGV[$_=pop]" is working... I'm glad I don't have to understand my solution =)
53.08 Juho Snellman Fri Aug 2 09:07:10 2002
-l $_=pop;for$~(pop=~/\w/g){s|$~(.*)|
$1
$~|}print//g
Change the separator from ~ to \n, to allow changing a \w to a .
53.09 Prakash Kailasa Wed Aug 7 03:31:06 2002
-l $_=pop;for$~(pop=~/./g){s|$~(.*)|
$1
$~|}print/./g
53.10 Eric Roode Thu Aug 1 21:48:15 2002
-l $_=pop;for$z(pop=~/./g){s/$z(.*)/
$1
$z/}print/./g
Breakthrough!
54.08 Prakash Kailasa Wed Aug 7 03:28:45 2002
-l $_=pop;for$~(pop=~/./g){s|$~(\w*)|
$1
$~|}print/./g
54.08 Juho Snellman Fri Aug 2 08:10:04 2002
-l $_=pop;for$p(pop=~/\w/g){s/$p(\w*)/~$1~$p/}print//g
Change from a map to a for loop (for the named loop variable), take advantage of the empty regexp.
54.09 Qingning Huo Wed Aug 7 15:39:29 2002
-l $_=pop;($~=pop)=~s}.}s~($&)(\w*)~
$2
$1~}eg;print//
54.09 Qingning Huo Wed Aug 7 15:50:47 2002
-l $_=pop;($~=pop)=~s}.}s~($&)(\w*)~
$2
$1~}eg|print??
54.10 Chris Dolan Mon Aug 5 23:14:12 2002
-l $ARGV[$_=pop]=~s^.^s~($&)(.*)~
$2
$1~^ge|print/\w/g
Multiline s///
54.12 Stephen Turner Sat Aug 3 20:38:41 2002
print s~(.)( |(.).+\3.*\1)~$2~?$1:$/while$2||s//@ARGV/
My fourth solution, and I've used three completely different algorithms.
55.08 Qingning Huo Tue Aug 6 12:48:10 2002
-l $_=pop;$ARGV[0]=~s}\w}s~($&)(\w*)~|$2|$1~}eg;print//
55.08 Wladimir Palant Thu Aug 1 11:28:10 2002
-l for$~(pop,pop=~/\w/g){s/$~(\w*)|$/ $1 $~/}print/\w/g
55.09 Chris Dolan Mon Aug 5 14:36:13 2002
-l $ARGV[$_=pop]=~s^.^s~($&)(\w*)~ $2 $1~^ge|print/\w/g
55.09 Prakash Kailasa Mon Aug 5 13:13:44 2002
-l $_=pop;for$z(pop=~/./g){s/$z(\w*)/ $1 $z/}print/\w/g
55.10 BoB (Best of Breed - referees) Thu Aug 1 10:55:09 2002
-l $}=pop;$}=~s/$_(.*)/
$1
$_/for pop=~/./g;print$}=~//
55.11 Qingning Huo Tue Aug 6 12:29:32 2002
-l $_=pop;$ARGV[0]=~s!\w!s/($&)(\w*)/~$2~$1/!eg;print//
55.11 Jukka Suomela Thu Aug 1 16:07:04 2002
-l $y=pop;$_=pop;$y=~s/$_(.*)/
$1
$_/for/./g;print< $y>
55.11 Jukka Suomela Thu Aug 1 17:02:56 2002
-l $}=pop;$_=pop;$}=~s/$_(.*)/
$1
$_/for/./g;print< $}>
55.12 Mtv Europe Tue Aug 6 11:43:55 2002
s~~@ARGV~;$/=$1.$/,s~$1~
~gwhile/(.)\D+\1.*
*$/;print$/
tie optimization
55.16 Jukka Suomela Thu Aug 1 18:55:39 2002
-l $_=pop;$ARGV[0]=~s#.#s/($&)(.*)/
$2
$1/#eg;print/./g
55.16 tinita Mon Aug 5 00:18:54 2002
-l $_=pop;$ARGV[0]=~s#.#s,($&)(.*),
$2
$1,#eg;print/./g
55.19 Mtv Europe Thu Aug 1 18:43:45 2002
s//@ARGV/;$/=$1.$/,s/$1/
/gwhile/(.)\C*\1.*
*$/;print$/
56.08 Wladimir Palant Thu Aug 1 11:09:01 2002
-l for$~($_=pop,pop=~/\w/g){s/$~(\w*)/ $1 $~/}print/\w/g
56.09 Prakash Kailasa Mon Aug 5 02:39:46 2002
-l $_=pop;for$z(pop=~/./g){s/$z(\w*)/ $1 $z/};print/\w/g
56.10 Jukka Suomela Thu Aug 1 16:01:26 2002
-l $_=pop;for$x(pop()=~/./g){s/$x(\w*)/
$1
$x/}print/./g
56.10 Jukka Suomela Thu Aug 1 16:05:47 2002
-l $y=pop;$_=pop;$y=~s/$_(\w*)/ $1 $_/for/./g;print< $y>
56.11 Markus Laire Thu Aug 8 01:45:51 2002
-l $_=pop;for$~(pop=~/./g){s/$~(.*)/
$1
$~/}s/
//g;print
56.13 Eugene van der Pijll Fri Aug 2 20:20:36 2002
$_="@ARGV";print$1while s/(.)(?=(.).*\2.*\1| )//;print$/
56.14 Mtv Europe Thu Aug 1 15:19:59 2002
$/=$1.$/while"@ARGV"=~m#([^$/]).*\1[^$/]*[$/]*$#;print$/
m// in golf??? am i going mad?
57.06 Michael Rybakin Tue Aug 6 12:48:34 2002
-l $_=pop;for$z(pop=~/./g){s|$z(\w*)|~\1~$z|}s|~||g^print
57.08 Qingning Huo Tue Aug 6 05:52:53 2002
-l $_=pop;$ARGV[0]=~s}.}s~($&)(\w*)~|$2|$1~}eg;print/\w/g
57.08 James Harvey Mon Aug 5 21:02:29 2002
-l s~.~@z=map/$&/?($`,$',$&):$_,pop||@z~egfor pop;print@z
should have spotted that...
57.09 Chris Dolan Mon Aug 5 14:14:48 2002
-l $_=pop;($z=pop)=~s^.^s|($&)(\w*)| $2 $1|^ge;print/\w/g
Fun tiebreaker algorithm, Ton.
57.09 Markus Laire Thu Aug 8 01:23:27 2002
-l $_=pop;for$~(pop=~/./g){s/$~(\w*)/-$1-$~/}s/-//g;print
57.10 BoB (Best of Breed - referees) Thu Aug 1 10:50:14 2002
-l $}=pop;$}=~s/$_(.*)/
$1
$_/for pop=~/./g;print$}=~/./g
57.10 Wladimir Palant Sat Aug 3 01:29:46 2002
-l s~~@ARGV~;$}.=$1while s~(.)(?=(.).*\2.*\1| )~~;print$}
57.12 Jukka Suomela Thu Aug 1 15:02:58 2002
-l $_="@ARGV";s/($&)(\w*)/ $2 $1/while s/^\w//;print/\w/g
57.16 Mtv Europe Thu Aug 1 13:23:43 2002
$_="@ARGV";$/=$1.$/,s/$1/ /gwhile/(\S).*\1\S* *$/;print$/
57.17 Honza Pazdziora Mon Aug 5 16:00:40 2002
$_="@ARGV";s/$+/ /g,$/=$&.$/while/(\S).*\1\S* *$/;print$/
57.18 Amir Karger Tue Aug 6 15:56:08 2002
-l $_="@ARGV";s/($&)(.*)/
$2
$1/while s/^.//;y/
//d;print
57.19 Ala Qumsieh Thu Aug 8 04:12:19 2002
$_="@ARGV";s/[$&]//,$/=$&.$/,s/$&/
/while/\w+
*$/;print$/
58.10 Prakash Kailasa Mon Aug 5 02:31:55 2002
-l $_=pop;for$z(pop=~/./g){s/$z(\S*)/ $1 $z/};y/ //d;print
58.11 Qingning Huo Mon Aug 5 20:38:01 2002
-l for(s//@ARGV/;s/(\w)(.+)\1(\w*)/$2~$3~$1/;){}print/\w/g
58.12 Josef Drexler Tue Aug 6 05:38:14 2002
-l $_=pop;for$x(pop=~/./g){s/(.*)$x(.*)/$1
$2
$x/}print//g
ahh, now *this* is golfable!
58.12 Wladimir Palant Sat Aug 3 01:19:17 2002
-l $_="@ARGV";$}.=$1while s~(.)(?=(.).*\2.*\1| )~~;print$}
58.15 Amir Karger Tue Aug 6 13:54:14 2002
-l $_=pop;($i=pop)=~s#.#s/($&)(.*)/
$2
$1/#ge;y/
//d;print
Hitting the wall?
58.15 tinita Sun Aug 4 23:41:03 2002
-l ($p,$_)=@ARGV;$p=~s#.#s/($&)(\w*)/ $2 $1/#eg;print/\w/g
58.17 Eugene van der Pijll Fri Aug 2 20:08:32 2002
$_="@ARGV";$a.=$1while s/(.)(?=(.).*\2.*\1| )//;print$a,$/
Small improvement in the algorithm.
58.19 Honza Pazdziora Thu Aug 1 17:59:43 2002
$_="@ARGV";/[$+]/,s/$&/ /g,$/=$&.$/while/.* (\S+)/;print$/
59.08 Wladimir Palant Thu Aug 1 11:05:18 2002
-l $~=~s/$_(\w*)/ $1 $_/for$~=pop,pop=~/\w/g;print$~=~/\w/g
59.09 BoB (Best of Breed - referees) Thu Aug 1 10:29:24 2002
-l $b=pop;$b=~s/$_(\w*)/ $1 $_/for pop=~/./g;print$b=~/\w/g
59.09 BoB (Best of Breed - referees) Thu Aug 1 10:43:52 2002
-l $}=pop;$}=~s/$_(\w*)/ $1 $_/for pop=~/./g;print$}=~/\w/g
59.09 Ross Younger Sun Aug 4 22:05:15 2002
-l for$}(pop=~/./g){@~=map/$}/?($`,$',$&):$_,@~,pop}print@~
59.09 James Harvey Sun Aug 4 20:59:36 2002
-l @z=pop;$_=pop;s~.~@z=map/$&/?($`,$',$&):$_,@z~eg;print@z
fiddling with tiebreaks
59.09 Juho Snellman Fri Aug 2 07:45:45 2002
-l $b=pop;map$b=~s/$_(\w*)/~$1~$_/,pop=~/./g;print$b=~/\w/g
Remove unneccessary parts from regexp, tweak tiebreaker.
59.11 James Harvey Sun Aug 4 17:02:19 2002
-l @l=pop;$_=pop;s;.;@l=map/$&/?($`,$',$&):$_,@l;eg;print@l
ick, ick, ick, had to swot up on previous post-mortems...
59.12 Stephen Turner Sat Aug 3 09:03:49 2002
-l $_="@ARGV";$}=$1.$},s~$1~
~gwhile/(.)\C+\1.*
*$/;print$}
I thought \X in place of \C would work, but it gives me a seg fault!
59.12 Qingning Huo Mon Aug 5 18:02:32 2002
-l for($_="@ARGV";s/(\w)(.+)\1(\w*)/$2~$3~$1/;){}print/\w/g
59.13 Chris Dolan Mon Aug 5 14:00:01 2002
-l $_=pop;($z=pop)=~s#.#s/($&)(.*?)\b/ $2 $1/#ge;print/\w/g
59.16 Jasper McCrea Sun Aug 4 16:19:52 2002
print eval'/((\w)(.*)\2(\w*))?
*$/s;$_="$2$`$3
$4".pop;'x29
(temporarily) puts me in front of all the beginners
60.09 BoB (Best of Breed - referees) Thu Aug 1 10:23:20 2002
-l $b=pop;$_=pop;$b=~s/$_(\w*)/ $1 $_/for/./g;print$b=~/\w/g
60.10 Markus Laire Thu Aug 8 00:48:41 2002
$_=pop;for$c(pop=~/./g){s/$c(\w*)/-$1-$c/;}s/-//g;print$_,$/
WOW, finally some real results...
60.12 Qingning Huo Mon Aug 5 17:42:57 2002
-l $_="@ARGV";9until!s/(.)(.+)\1(\w*)\b/$2~$3~$1/;print/\w/g
60.13 Jukka Suomela Thu Aug 1 14:45:53 2002
-l $_="@ARGV";1while s/^(\w)(.*)\1(\w*)/$2 $3 $1/;print/\w/g
60.15 Ala Qumsieh Thu Aug 8 03:18:00 2002
$_=pop;$ARGV[0]=~/[$&]/,$/=$&.$/,s/$&/
/while/.+
*$/;print$/
60.30 Honza Pazdziora Thu Aug 1 16:31:14 2002
$_="@ARGV";/[$+]/,$/=$&.$/,s/$&/ /g while/ (\S+) *$/;print$/
61.09 Wladimir Palant Thu Aug 1 10:19:50 2002
-l $b=pop;$b=~s/$_(\w*)/ $1 $_/for(pop=~/\w/g);print$b=~/\w/g
61.12 Prakash Kailasa Mon Aug 5 02:25:18 2002
-l $_=pop;s/($&)(\S*)/ $2 $1/while$ARGV[0]=~/./g;y/ //d;print
61.13 Qingning Huo Mon Aug 5 17:20:10 2002
-l $_="@ARGV";9while s/(\w)(.+)\1(\w*)\b/$2 $3 $1/;print/\w/g
62.10 Ross Younger Sat Aug 3 21:33:00 2002
-l @a=pop;for$b(pop=~/./g){@a=map/$b/?($`,$',$&):$_,@a}print@a
62.10 Dr. Mu Sat Aug 3 16:55:05 2002
-l $_=pop;for$x(pop=~/./g){s/(\w*)$x(\w*)/$1 $2 $x/}print/\w/g
62.12 Amir Karger Tue Aug 6 13:01:02 2002
-l @i=pop;$_=pop;
s#.#@i=map{/$&/?($`,$',$&):$_}@i#ge;
print@i
Eight strokes, and it doesn't move me up even one place in the rankings?!
62.14 Jukka Suomela Thu Aug 1 14:41:50 2002
-l $_="@ARGV";1while s/^(\w)(.*)\1(\w*)/$2 $3 $1/;s/ //g;print
63.09 Wladimir Palant Thu Aug 1 10:13:25 2002
-l $b=pop;$_=pop;$b=~s/$_(\w*)/ $1 $_/for(/\w/g);print$b=~/\w/g
63.10 Wladimir Palant Sat Aug 3 00:37:40 2002
-l $_=join z,@ARGV;$}.=$1while s~(.)(?=(.).*\2.*\1|z)~~;print$}
Oops, of course it can be improved...
63.11 Stephen Turner Fri Aug 2 15:41:17 2002
-l $_=pop;$ARGV[0]=~/[$&]/,$}=$&.$},s~$&~
~while/.+
*$/;print$}
63.12 Chris Dolan Mon Aug 5 13:57:52 2002
-l $_=pop;($z=pop)=~s#.#$z=$&,s/$z(.*?)\b/ $1 $z/#ge;print/\w/g
63.12 Matthias Schoder Tue Aug 6 15:58:17 2002
-l $_=pop;for$a(pop=~/./g){s/^(.*)$a(.*)$/$1
$2
$a/gm}print/./g
63.15 Josef Drexler Tue Aug 6 05:27:34 2002
-l $_=pop;s/(.*)($&)(.*)/$1
$3
$2/while$ARGV[0]=~/./g;print/./g
now non-recursive, and without the broken $^S
63.16 Qingning Huo Mon Aug 5 17:12:52 2002
-l $_="@ARGV";9while s/(\w)(.+)\1(\w*) */$2 $3 $1/;y/ //d;print
63.17 Jasper McCrea Sun Aug 4 14:38:01 2002
eval's/((.*?)(\w)(.*)\3(\w*))?
*$/"$3$2$4
$5".pop/es;'x29;print
only 14 to go :)
64.09 James Harvey Fri Aug 2 11:25:40 2002
-l @l=pop;for$t(split//,pop){@l=map/$t/?($`,$',$&):$_,@l}print@l
64.17 Honza Pazdziora Thu Aug 1 14:48:11 2002
($y,$_)=@ARGV;$y=~/[$+]/,$/=$&.$/,s/$&/ /while/(\S+) *$/;print$/
65.07 Chris Dolan Fri Aug 2 14:08:29 2002
-l sub z{my$z=shift;map(&z,/[^$z]+/g),$z}$_=pop;print z pop=~/./g
65.08 Eric Roode Thu Aug 1 20:30:47 2002
@x=pop;for$n(pop=~/./g){@x=map+(split/($n)/)[0,2,1],@x}print@x,$/
65.08 Eric Roode Thu Aug 1 21:28:38 2002
-l @x=pop;for$n(pop=~/./g){@x=map+(split/($n)/)[0,2,1],@x}print@x
65.09 Josef Drexler Mon Aug 5 00:46:28 2002
$_||=pop;$ARGV[0]=~/./g;s/$&/ /;do$0for split;print$&,!caller&&$/
back to the previous approach, looks more golfable
65.10 Matthias Schoder Tue Aug 6 15:45:37 2002
-l $_=pop;for$a(pop=~/./g){s/^(.*)$a(.*)$/$1\n$2\n$a/gm}print/./g
65.15 Mtv Europe Thu Aug 1 11:57:02 2002
-l $z="@ARGV";$_=$1.$_ while$z=~s/(\S)(.*)\1(\S*) *$/$2 $3/;print
breakthrough
65.17 Jasper McCrea Sun Aug 4 11:08:30 2002
s/(.*?)(\w)(.+)\2(\w*)
*$|\s+/$2$1$3
$4/sfor($_="@ARGV")x27;print
yuck
66.09 Eric Roode Thu Aug 1 19:35:42 2002
@x=pop;for$n(pop=~/./g){@x=map+(split/($n)/)[0,2,1],@x}print@x,"
"
Some obvious optimizations
66.10 Juho Snellman Fri Aug 2 07:26:03 2002
-l $b=pop;map$b=~s/(\w*)$_(\w*)/$1 $2 $_/,pop=~/./g;print$b=~/\w/g
I was really happy with my (unsubmitted) 148 solution, until I checked the leaderboard. There's no way a 50 could be anything but a regexp solution, so I came up with this.
66.10 Dr. Mu Sat Aug 3 05:56:59 2002
-l $_=pop;for$x(split'',pop){s/(\w*)$x(\w*)/$1 $2 $x/}s/ //g;print
66.11 Ala Qumsieh Thu Aug 8 01:20:15 2002
-l $i=pop;$_=pop;$i=~/[$&]/,$y=$&.$y,s/$&/
/while/\w+
*$/s;print$y
67.07 Chris Dolan Fri Aug 2 13:50:15 2002
-l sub z{my$y;map($_&&&z,split$y=shift),$y}$_=pop;print z pop=~/./g
67.10 Wladimir Palant Thu Aug 1 10:09:22 2002
-l $b=pop;$_=pop;$b=~s/$_(\w*)/ $1 $_/for(/\w/g);$b=~s/ //g;print$b
67.14 Honza Pazdziora Thu Aug 1 14:02:48 2002
-l ($y,$_)=@ARGV;$y=~/[$+]/,$z=$&.$z,s/$&/ /while/(\S+) *$/;print$z
68.17 Jasper McCrea Sun Aug 4 00:22:54 2002
-l s/(.*?)(\w)(.*)\2(\w*-*)$/$2$1$3-$4/for($_="@ARGV")x26;print/\w/g
this looks more like it, but I'm totally stuck
69.10 Matthias Schoder Tue Aug 6 15:29:38 2002
-l $_=pop;for$a(pop=~/./g){s/^(.*)$a(.*)$/$1\n$2\n$a/gm}s/\n//g;print
70.13 Amir Karger Mon Aug 5 20:33:31 2002
-l ($_,@i)=@ARGV;
while(/./g){
@i=map{/$&/?($`,$',$&):$_}@i;
}
print@i
I guess this is a better algorithm!
71.07 Rick Klement Thu Aug 1 22:32:20 2002
for(pop=~/./g,$/,$~=pop){print+pop@~while@~x$~!~/$~[-1].*$_/;push@~,$_}
cool, a complete YACC style shift/reduce parser...
71.09 Josef Drexler Sun Aug 4 23:41:44 2002
-l sub z{$ARGV[0]=~/./g;my$c=$&;(map$_?&z:'',split$c),$c}$_=pop;print z
72.07 Chris Dolan Fri Aug 2 02:42:58 2002
sub r{map/$_[0]/&&&r,split my$n=shift;print$n}$_=pop;r pop=~/./g;print$/
73.15 Matthias Schoder Tue Aug 6 13:03:16 2002
-l $_=" $ARGV[0] ";for$a(pop=~/./g){s/( .*)$a(.*? )/$1 $2$a/}s/ //g;print
74.09 Matthias Schoder Sat Aug 3 21:41:48 2002
sub P{pop=~/./;my$x=$&;map$_&&P($_,$'),split$x,pop;print$x}P@ARGV;print"
"
74.10 Wladimir Palant Sat Aug 3 00:32:50 2002
-l $_=join z,@ARGV;$}.=$1while s~(.)(.)(?=.*\2.*\1)~$2~||s~(.)z~z~;print$}
Just an interesting solution, I wonder if this can be improved
75.08 Matthias Schoder Sat Aug 3 21:24:38 2002
sub P{pop=~/./;my$x=$&;map$_&&P($_,$'),split$x,pop;print$x}P@ARGV;print"\n"
75.12 Ala Qumsieh Wed Aug 7 17:48:14 2002
-l $i=pop;$_=pop;$i=~/[$&]/,$y=$&.$y,s/(.*)$&(\w*)/$2 $1/while/\w+/;print$y
slightly better ...
76.07 Eike Grote Wed Aug 7 07:38:27 2002
$~=pop;sub'z{$~=~/./g;my$z=$&;$_&&z($_)for split$z,pop;print$z}z pop;print$/
76.10 Bass Sun Aug 4 17:46:53 2002
-l $_=pop;while(/./g){$~=$&;/\G.?/;s|$~||,$o.=$~if$ARGV[0]=~/$&.*$~/}print$o
the stack approach w/o the stack. long way to go still
78.09 Josef Drexler Fri Aug 2 04:26:52 2002
-l $t||=pop;$_||=pop;s/.//,$c=$&for$t;/$c/;do$0for$`,$';$o.=$&;caller||print$o
first time I've seen "caller" used in Perl Golf
78.13 Alexander Onokhov Mon Aug 5 23:48:14 2002
-l sub f{"@_"&&(s/.//&&pop=~/$&/&&eval"f('$`').f('$'').$&")}$_=pop;print f pop
79.07 Chris Dolan Fri Aug 2 01:30:15 2002
sub r{/$p[$x]/&&r()for split my$n=$p[$x++];print$n}$_=pop;r@p=pop=~/./g;print$/
79.09 Eric Roode Thu Aug 1 19:20:01 2002
@x=pop;foreach$n(pop=~/./g){@x=map+(split/($n)/)[0,2,1],@x;}print grep$_,@x,"
"
79.10 Stephen Turner Fri Aug 2 08:29:44 2002
$_|=pop;$z|=pop;/[$z]/;$}+=$z=~/$&/;do$0if$z=$`;do$0if$z=$';--$}or$\=$/;print$&
16 strokes just to put a \n in the right place.
80.07 tinita Fri Aug 2 09:25:59 2002
-l sub _{do{$ARGV[0]=~m/./g;my$r=$&;(map{_($_)}split$r),$r}if$_=pop}print _(pop)
80.12 Prakash Kailasa Mon Aug 5 02:14:24 2002
-l ($p,$i)=@ARGV;while($p=~/./g){$r=$&;$i=~s/$r(\S*)/ $1 $r /}$i=~y/ //d;print$i
81.08 Bass Fri Aug 2 09:34:38 2002
-l for($_=pop;s~(.*)\b(\w)~$1~;$}=$2.$}){$z=index$y||=pop,$2;s~.{$z}~$& ~}print$}
but which 30 characters to drop..
82.08 Ross Younger Sat Aug 3 08:51:55 2002
for$b(pop=~/./g){$_=pop;/$b/||print&&redo;push@ARGV,$&,$',$`}print reverse$/,@ARGV
My head hurts!
82.16 Aj Tue Aug 6 17:19:36 2002
$_="@ARGV
";print($y=$5||$1||$&),s/$y//gwhile/(.)(.)(.).*(\2\1|\1(\2)(?!.*\3))|.
/
83.09 Josef Drexler Fri Aug 2 03:12:38 2002
-l $t||=pop;$_||=pop;$a++;/@{[do{$t=~s#.##;$&}]}/;do$0for$`,$';$o.=$&;--$a||print$o
too bad $& isn't localized *before* a match, that would make life easier...
84.09 Ala Qumsieh Wed Aug 7 16:21:37 2002
-l $_=pop;while(@ARGV){$i=pop||next;/[$i]/;$y=$&.$y;$i=~/$&/;push@ARGV,$`,$'}print$y
a bit better .. not enough though :(
85.10 Jasper McCrea Sat Aug 3 20:55:29 2002
-l ($p,$_)=@ARGV;Z:split;for$l($p=~/./g){s/$l/ /,$o=$l.$o,goto Z if$_[-1]=~$l}print$o
wayhey! goto! Now I'm a real programmer!
85.10 Bass Fri Aug 2 07:10:05 2002
-l map$ARGV[0]=~s/(\w*)$_(\w*)/$1~$2/&@o[++$n+length$1.$2]=~s/^/$_/,pop=~/./g;print@o
todo: make this into a regex.. :-)
87.09 Guillermo Sansovic Sun Aug 4 13:15:27 2002
-l sub f{$_=pop;$ARGV[0]=~/[ $_]/;my$r=$&;$_&&join('',map{f($_)}split$&).$r}print f pop
87.09 Matthias Schoder Sat Aug 3 13:36:31 2002
sub P{$_[0]=~s/(.)//;my$x=$1;map{$_&&P($_[0],$_)}split$x,$_[1];print$x}P@ARGV;print"\n"
87.10 Markus Laire Tue Aug 6 18:33:30 2002
$_=pop;($~=pop)=~/../?/./g+$~=~/$&/<push@ARGV,$&,$',$`:/$~/gc<print$~while@ARGV;print$/
88.29 gimbo Sat Aug 3 13:00:26 2002
-l s//@ARGV/;$=+=26*s/^(.)(.{$=})(.*) (.{$=})\1(.*)/$2 $4
$3 $5
$1/mwhile$=--;print/\w/g
89.10 Josef Drexler Thu Aug 1 23:58:08 2002
-l $_||=pop;$i=pop||$`||die;$a++;s/.//;$i=~s/$&//;do$0;{$'=~/$/;do$0}$o.=$&;--$a||print$o
89.10 me ELOISE Wed Aug 7 20:42:17 2002
sub f{s/.//;my($e,$o,$i)=split/($&)/,pop;$e&&f($e);$i&&f($i);print$o}$_=pop;f pop;print$/
not exactly the paradigm shift I need, but a tidy shave.
90.10 tinita Thu Aug 1 13:48:37 2002
-l sub
_{if(my$i=pop){$ARGV[0]=~/(.)/g;my$r=$1;$i=~s/(.*)$r//;_($1)._($i).$r}}print
_(pop)
well, first try, last one on leaderboard, but at least it runs with -w =)
91.09 Jasper McCrea Sat Aug 3 17:28:03 2002
-l ($p,$_)=@ARGV;while(split){for$l($p=~/./g){s/$l/ /,@a=($l,@a),last if$_[-1]=~$l}}print@a
getting better, but plenty of room yet (I hope)
91.10 Martin Carlsen Sat Aug 3 22:08:35 2002
-l sub f{$i=pop||return;/[$i]/;$i=~/$&/;my($m,$r)=($&,$');f($`).f($r).$m}$_=pop;print f pop
91.16 Mtv Europe Mon Aug 5 08:17:22 2002
/./g,pop=~$&,$~=$`,$z=$',/.{$-[0]}/g,$_=`$^X $0 $~ $&`.`$^X $0 $z $'`.$`,print/./g,$/if$_=pop
is it shortest recursive postorder?
93.12 Amir Karger Mon Aug 5 16:56:13 2002
-l sub n{
if(my$i=pop){
s/.?/pop/e;
my$n=$&;
$i=~s/(.*)$n//;
n($1).n($i).$n}
}
print n(@ARGV)
95.13 Aj Tue Aug 6 13:05:06 2002
$_="@ARGV
";print($y=$5||$6),s/$y//g while/(.)(.)(.).*(\1(\2)(?!.*\3)|\2(\1))/;print substr$_,2
96.14 Qingning Huo Mon Aug 5 12:20:35 2002
-l sub p{p($`,$3),p(@_[1,3]),$_[0]if!!(@_="@_"=~/(.)(.*) \1((??{".{$-[1]}"}))(.*)/)}print p@ARGV
96.15 Mtv Europe Thu Aug 1 07:28:09 2002
-l $_=shift;/./g;pop=~$&;$y=$`;$z=$';/.{$-[0]}/g;$_=$`&&`$^X $0 $& $y`.`$^X $0 $' $z`.$`;print/./g
hehe
96.16 Keith Calvert Ivey Wed Aug 7 13:11:43 2002
-l s~~@ARGV~;s~(.*)(.)(.*) \2((??{"[|$1]*"}))(.*)| ~$\=$2.$\;$2&&"$3 $5
$1 $4"~ewhile/./;print@}
I like this one much better than the 97, though 1 stroke hardly makes much difference when I'm 9 behind the next guy and 56 behind the leader.
97.08 me ELOISE Tue Aug 6 18:24:56 2002
sub f{my$n=pop||return;s/.//;my($e,$o,$i)=split/($&)/,$n;f($e);f($i);print$o}$_=pop;f pop;print$/
97.10 Michael Wrenn Wed Aug 7 19:18:05 2002
-l split//,pop;$_=pop;1while++$}<@_&/$_[$z].*$_[$}]/&&(@_[$z,$}]=@_[$},$z])||($}=++$z)<@_;print@_
Happiness is breaking 100 after so many tries!
97.14 Keith Calvert Ivey Wed Aug 7 02:32:55 2002
-l s~~@ARGV
~;s~(.?)(.*) (.*)\1(.*)
~$1&&($\=$1.$\,substr$2,length$3)." $4
$2 $3
"~ewhile$_;print
98.10 Josef Drexler Thu Aug 1 05:59:06 2002
-l $_=pop;sub d{my$i=pop;s/.//;$i=~/$&/;my($s,$t)=($&,$');d($`)if$`;d($t)if$t;$o.=$s}d pop;print$o
this one I like.
98.19 Keith Calvert Ivey Wed Aug 7 12:13:23 2002
-l s~~@ARGV
~;s~((.*)(.)(.*) \3((??{"[|$2]*"}))| )(.*)
~$\=$3.$\;$3&&"$4 $6
$2 $5
"~ewhile$_;print
I like this one better than my last, but it's one stroke longer. Too bad I can't get rid of the messy way of dealing with empty subtrees.
99.08 Keith Calvert Ivey Tue Aug 6 02:52:27 2002
-l while(@ARGV){pop=~/./;($_,$})=split$&,pop||next;$\=$&.$\;push@ARGV,$_,$',$},substr$',y|||c}print
Progress at last! This shows more promise.
99.08 me ELOISE Tue Aug 6 03:25:23 2002
sub f{my$n=pop||return;s/(.)//;my($e,$o,$i)=split/($1)/,$n;f($e);f($i);print$o}$_=pop;f pop;print$/
99.10 Petri Mikkelä Wed Aug 7 14:31:15 2002
-l sub x{($z,$_)=@_;$z=~s/./"s~$&~\$w=$&.\$w;x substr('$'',pos),\$';x '$'',\$`~e"/ee}x@ARGV;print$w
100.09 me ELOISE Mon Aug 5 22:39:18 2002
sub f{my$n=pop||return;s/(.)//;my($e,$o,$i)=split/($1)/,$n;f($e);f($i);print$o}$_=pop;f@ARGV;print$/
100.10 Michael Wrenn Wed Aug 7 15:45:00 2002
-l split//,pop;$_=pop;1while++$~<99&/$_[$}].*$_[$~]/&&(@_[$},$~]=@_[$~,$}])||($}=$~=$z++)<99;print@_
Whew! I'm almost out of breath! Some of us are still working here at the back of the pack!

Keep running, and don't look back, they might be gaining on you

100.11 Markus Laire Tue Aug 6 12:52:07 2002
($P,$I)=@ARGV;sub z{$P=~s/.//;$~=~/$&/;my$b=$';my$v=$&;&z if$~=$`;&z if$~=$b;print$v}$~=$I;z;print$/
100.15 Marko Nippula Sun Aug 4 15:49:42 2002
-l sub z{z(@_[0,3]),z(@_[2,4]),@_[1]if(@_=("@_"=~/(.*)(.)(.*) \2/,$'=~/([_$1]*)/,$'))>4}print z@ARGV
Phuh. Finally at 100. But still long way to go...
101.09 me ELOISE Mon Aug 5 22:33:51 2002
sub f{my$n=pop||return;s/(.)//;my($e,$o,$i)=split/($1)/,$n;f($e);f($i);print$o;}$_=pop;f@ARGV;print$/
102.10 Jasvir Nagra Wed Aug 7 23:53:32 2002
sub r{pop=~/./;my$r=$&,$s=$';pop=~/$r/;my$t=$';push@_,$`,$s;$`&&&r;$t&&r($t,$s);print$r}r@ARGV;print$/
102.14 Qingning Huo Mon Aug 5 09:15:12 2002
-l sub p{p(@_[0,3]),p(@_[2,4]),$_[1]if!!(@_="@_"=~/(.*)(.)(.*) \2((??{".{$+[1]}"}))(.*)/)}print p@ARGV
104.08 James Harvey Fri Aug 2 09:42:47 2002
-l $p=pop;sub z{$_=pop||return;$p=~s/^.//;my$f=$&;my($i,$j)=split/$&/;return z($i).z($j).$f}print z(pop)
104.09 Michael Wrenn Wed Aug 7 15:31:47 2002
-l split//,pop;$_=pop;1while$~<99&/${_[$z]}.*${_[++$~]}/&&(@_[$z,$~]=@_[$~,$z])||($z=$~=$x++)<99;print@_
Still at #25, but I am aiming for a sub 100 postorder. Time will tell.
106.09 Erik Beatty Mon Aug 5 22:48:29 2002
sub p{if(my$t=pop){$p=~s/^\w//;my$c=$&;$t=~/$c/;my$l=$`;my$r=$';p($l);p($r);$a.=$c}}$p=pop;print p(pop),$/
Found the extra space, '#!perl '... stupid space after the 'l'...
107.09 Erik Beatty Mon Aug 5 21:55:30 2002
 sub p{if(my$t=pop){$p=~s/^\w//;my$c=$&;$t=~/$c/;my$l=$`;my$r=$';p($l);p($r);$a.=$c}}$p=pop;print p(pop),$/
just noticed 2 extra chars..
107.10 Michael Wrenn Wed Aug 7 15:14:22 2002
-l split//,pop;$_=pop;1while($y=$_[++$~])&&(/${_[$z]}.*$y/)&&(@_[$z,$~]=@_[$~,$z])||($z=$~=$x++)<99;print@_
Number 25 again! So much work to stay in the same place.
108.08 Keith Calvert Ivey Mon Aug 5 12:42:47 2002
-l sub'z{pop=~/./;$_=pop;my$z=$';split$&;$_&&{$\=$&.$\}&z(pop,substr$z,length$_[0])|z(shift,$z)}print+z@ARGV
Well, I've passed Yanick for now, but several other people have passed me, so my position is dropping.
108.09 Erik Beatty Fri Aug 2 22:35:35 2002
sub p{if(my$t=pop){$p=~s/^\w//;my$c=$&;$t=~/$c/;my$l=$`;my$r=$';p($l);p($r);$a.=$c}}$p=pop;p(pop);print$a,$/
changed thinking.. getting better..
108.10 Michael Robinson Mon Aug 5 06:37:36 2002
-l while(@ARGV){$_=pop;s/(.)//&&do{$o=$1.$o;pop=~/$1/;push@ARGV,$`,substr($_,0,length($`),''),$',$_}}print$o
Minor refinement; eliminate next for an if type construct.
108.17 Ala Qumsieh Tue Aug 6 17:33:51 2002
-l $_="@ARGV";1while s|(.*)(.)(.*) \2(.*)|@_=$3?split/([$3]+)/,$4:$4;$y=$2.$y;"
$3 $_[1]
$1 $_[0]"|e;print$y
109.10 Michael Robinson Sun Aug 4 03:42:21 2002
while(@ARGV){$_=pop;s/(.)//||next;$o=$1.$o;pop=~/$1/;push@ARGV,$`,substr($_,0,length($`),''),$',$_}print"$o
"
Doh! No need for a function at all; just a while loop, and a manual stack manipulation.
109.14 Qingning Huo Mon Aug 5 08:50:55 2002
-l sub p{p(@_[1,3]),p(@_[2,4]),$_[0]if!!(@_="@_"=~/(.)(.*)(.*) ((??{".{@{[$+[2]-1]}}"}))\1(.*)/)}print p@ARGV
110.08 Yanick Champoux Sat Aug 3 17:42:25 2002
sub
t{if(@p&&(my$k=pop)>($m=index$ARGV[0],$p[0])){my$x=shift@p;t($m);t($k);print$x}}t
1+(@p=pop=~/./g);print$/
I suck. :(
110.08 Keith Calvert Ivey Mon Aug 5 01:53:23 2002
-l sub'z{pop=~/./;$_=pop;my$z=$';split$&;$_&&($\=$&.$\)&z($_[1],substr$z,length$_[0])|z(shift,$z)}print+z@ARGV
Still 0.02 behind Yanick!
110.09 Michael Wrenn Tue Aug 6 20:27:17 2002
-l split//,pop;1while(index$z||=pop,$_[$y])<(index$z,$_[++$~])&&(@_[$y,$~]=@_[$~,$y])||($y=$~=$x++)<99;print@_
Back in the top 25 as I cruise past the day 1 version of Yanick by a mere whisker ...
111.08 Michael Wrenn Tue Aug 6 16:21:07 2002
-l split//,pop;$z=pop;while(($y=$~=$x++)<99){@_[$y,$~]=@_[$~,$y]while index($z,$_[$y])<index$z,$_[++$~]}print@_
May I proceed to the next stop the rankings? Only one more stroke.
111.10 Prakash Kailasa Sun Aug 4 18:56:29 2002
-l sub z{$_[0]=~/./?do{pop=~/$&/,@_=($`,$',unpack"aa$-[0]a*",pop);z(@_[3,0]).z(@_[4,1]).@_[2]}:pop}print+z@ARGV
112.08 Keith Calvert Ivey Sun Aug 4 19:34:32 2002
-l sub'z{pop=~/./&&($_=pop)&&do{$\=$&.$\;@_=($',split$&);z(pop,substr$_[0],length$_[1]);z(pop,pop)}}print+z@ARGV
Still haven't had The Insight, so I'll keep nibbling at this one.
113.09 Yanick Champoux Sat Aug 3 14:38:52 2002
-l sub
t{if(@p&&(my$k=pop)>($m=index$ARGV[0],$p[0])){my$z=shift@p;grep$_,t($m),t($k),$z}}print t 1+(@p=pop=~/./g)
113.09 Keith Calvert Ivey Sun Aug 4 13:49:55 2002
-l sub'z{pop=~/./&&($_=pop)&&do{my($w,$x,$y,$z)=($',$&,split$&);z($y,$w),z($z,substr$w,length$y),$x}}print+z@ARGV
113.11 Jasvir Nagra Tue Aug 6 00:55:09 2002
sub r{my($r,$s)=pop=~/(.)(.*)/;pop=~/$r/;my($e,$t)=($`,$');$u=$s;$e&&r($e,$s);$t&&r($t,$u);print$r}r@ARGV;print$/
This is still shocking - two my's and all. *sigh*
113.15 Qingning Huo Mon Aug 5 06:40:03 2002
-l sub p{!!(@_="@_"=~/^(.)(.*)(.*) ((??{".{@{[$+[2]-1]}}"}))\1(.*)$/)&&(p(@_[1,3]),p(@_[2,4]),$_[0])}print p@ARGV
114.09 Yanick Champoux Sat Aug 3 00:09:34 2002
-l sub
t{my$k=pop;if(@p&&$k>($m=index$ARGV[0],$p[0])){my$z=shift@p;t($m),t($k),$z}}print grep$_,t 1+(@p=pop=~/./g)
114.09 Michael Wrenn Tue Aug 6 16:04:11 2002
-l split//,pop;$z=pop;while(($~=$y++)<99){@_[$y-1,$~]=@_[$~,$y-1]while index($z,$_[$y-1])<index$z,$_[++$~]}print@_
Moving up one to the "!last" spot. A few more to catch Yanick with his hands tied behind his back.
114.12 Martin Carlsen Sat Aug 3 21:03:57 2002
sub f{my($p,$i)=@_;$p=~/[$i]/;$i=~/$&/;my($l,$m,$r)=($`,$&,$');$l&&f($p,$l);$r&&f($p,$r);print$m;}f@ARGV;print"\n"
115.19 Ala Qumsieh Tue Aug 6 17:18:58 2002
-l $_="@ARGV";while(s/(.*?)(.)(.*) \2(.*)//){@_=$3?split/([$3]+)/,$4:$4;$_="
$3 $_[1]
$1 $_[0]".$_;$y=$2.$y}print$y
At least get my name on the leaderboard!! Some optimizations coming up ...
116.10 Prakash Kailasa Sat Aug 3 03:28:51 2002
-l sub z{$_[0]=~/(.)./?do{pop=~/$1/,@_=(unpack("aa$-[0]a*",pop),$`,$');z(@_[1,3]).z(@_[2,4]).@_[0]}:pop}print+z@ARGV
117.09 Yanick Champoux Thu Aug 1 22:16:51 2002
-l sub
t($){my$k=pop;if(@p&&$k>($m=index$ARGV[0],$p[0])){my$z=shift@p;t($m),t($k),$z}}print grep$_,t 1+(@p=pop=~/./g)
117.12 Prakash Kailasa Fri Aug 2 15:39:31 2002
-l sub p{($_,$z)=@_;/(.)./?do{$z=~/$1/,@_=(unpack("aa$-[0]a*",$_),$`,$');p(@_[1,3]).p(@_[2,4]).@_[0]}:$z}print+p@ARGV
118.09 Bass Thu Aug 1 13:11:31 2002
-l $i=pop;while(@ARGV){$_=pop;s/.//||next;@o=($&,@o);$i=~s/([^~]*)$&/$1~/;
$l=length$1;push@ARGV,/(.{$l})(.*)/}print@o
brains.. hurt.. on the first try..
119.14 Jasper McCrea Sat Aug 3 13:29:12 2002
-l sub e{my($l,$t,$r,$k,$e)="@_"=~/(.*)(.)(.*) \2/;$l=~$_?$k:$e.=$_ for$'=~/./g;$t&&(e($l,$k),e($r,$e),$t)}print e@ARGV
ref, not sure why last one rejected. e@ARGV works for me.
120.08 Keith Calvert Ivey Sun Aug 4 13:23:36 2002
-l sub'z{pop=~/./&&do{my($w,$x,$y,$z)=($',$&,split$&,pop);z($y,_ x length$y&$w),z($z,substr$w,length$y),$x}}print+z@ARGV
Finally passed somebody, but still on a dead-end path
120.09 me ELOISE Mon Aug 5 20:36:37 2002
sub f{my($r,$n)=@_;$n||return$r;$r=~s/(.)//;my($o)=$1;my($e,$i)=split/$o/,$n;$r=f(f($r,$e),$i);print$o;$r}f@ARGV;print$/
120.14 Qingning Huo Sun Aug 4 08:31:52 2002
-l sub p{@_="@_"=~/^(.)(.*)(.*) ((??{".{@{[$+[2]-1]}}"}))\1(.*)$/;$_[1]&&p(@_[1,3]),$_[2]&&p(@_[2,4]),$_[0]}print p@ARGV
120.14 Markus Laire Mon Aug 5 15:49:15 2002
sub p{my($i,$p)=@_;$i=$1,@_=($4,substr$p,1+length$3),p($3,$2).&p.$i if"$p!$i"=~/(.)(.*)!(.*)\1(.*)/}print p(@ARGV)."\n";
121.08 Roberto Natella Sun Aug 4 10:18:42 2002
-l sub
n{local($_)=@_;return if!s/.//;@_=split my$e=$&,pop;$m=length$_[0];s/.{$m}//;n($&,shift).n($_,pop).$e}print n@ARGV
123.09 Roberto Natella Sat Aug 3 17:28:39 2002
-l sub
n{local($_)=@_;return if!s/.//;@_=split$&,pop;my$e=$&;$m=length$_[0];s/.{$m}//;n($&,shift).n($_,pop).$e}print n@ARGV
123.11 Jasvir Nagra Sun Aug 4 04:41:29 2002
sub r{($_,$i)=@_;my($r,$s)=/(.)(.*)/;$i=~/$r/;my($e,$t)=($`,$');r($s,$e)if$e;r(substr($_,1),$t)if$t;print$r;}r@ARGV;print$/
Just something to get going with.
123.12 Marko Nippula Thu Aug 1 14:01:05 2002
-l sub z{if($_[0]=~s/.//){$_[1]=~/$&/;my($z,$x)=($`,$');$_="$&$_";$_[0]=~/[_$z]*/;my$y=$&;z("$'",$x);z($y,$z)}}z@ARGV;print
124.09 Keith Calvert Ivey Sun Aug 4 03:17:02 2002
-l sub'z{$_[0]=~/./&&do{my($m,$o,$p,$q)=($',$&,split$&,pop);z(_ x length$p&$m,$p),z(substr($m,length$p),$q),$o}}print+z@ARGV
124.09 Michael Wrenn Tue Aug 6 14:46:47 2002
-l split//,pop;$z=pop;while(($~=$y)<99){@_[$~-1,$~]=@_[$~,$~-1]while index($z,$_[$~])<index$z,$_[++$~];$~-$y-1||$y++}print@_
Fix those tie-breakers - just in case ...
125.08 Nik L Tue Aug 6 06:49:51 2002
-l sub c{my$j=shift@p;for(pop=~/(.*)$j(.*)/){if(/^.$/){$o.=$_;shift@p}else{c($_)if/./}}$o.=$j}@p=split//,shift;c(pop);print$o
125.12 Prakash Kailasa Fri Aug 2 03:27:26 2002
-l sub p{($_,$q)=@_;/(.)./?do{$q=~/$1/,@_=(unpack(aa.$-[0].a.length$',$_),$`,$');p(@_[1,3]).p(@_[2,4]).$_[0]}:$q}print+p@ARGV
127.08 Brad Jones Thu Aug 1 23:03:50 2002
-l sub z{if(@_>1){my($y,$x)=split/$_[0]/,pop;z(@_[1..length$y],$y).z(@_[1+length$y..$#_],$x).$_[0]}}print z((split//,pop),pop);
Remove another variable, saving 4 more characters.
127.09 Keith Calvert Ivey Sun Aug 4 02:09:41 2002
-l sub'z{my($m)=@_;$m=~s/.//&&do{my($o,$p,$q)=($&,split$&,pop);z(_ x length$p&$m,$p).z(substr($m,length$p),$q).$o}}print+z@ARGV
127.09 Michael Wrenn Mon Aug 5 21:55:58 2002
-l $_=pop;$p=pop;while(($m=$c)<26){split//;1while index($p,$j=$_[$c])<index$p,$_[++$m];s/.{$m}/$&$j/;s/$j//;$m-$c-1||$c++}print
128.11 Eugene van der Pijll Fri Aug 2 18:54:56 2002
-l sub a{($_,my$I)=@_;s/.//;my$p=$_ or return$I;my($z,$x,$y)=($&,split$&,$I);a(/[z$x]+/g,$x),a($p=~/[z$y]+/g,$y),$z}print a@ARGV
Resubmission of accidently rejected solution. But with a better tiebreaker!
128.13 Mtv Europe Thu Aug 1 05:51:35 2002
-l sub f{"@_"=~/./;my@b=$_[1]=~/(.*)$&(.*)/;my@a=$_[0]=~/(.)(.{$+[1]})(.*)/;$_[0]&&f($a[1],@b).f($a[2],$b[1]).$a[0]}print f@ARGV
just to clear the "200" hurdle
130.09 Brad Jones Thu Aug 1 22:31:00 2002
-l sub z{if(@_>1){my($y,$x,$z)=split/$_[0]/,pop;$z=length$y;z(@_[1..$z],$y).z(@_[$z+1..$#_],$x).$_[0]}}print z((split//,pop),pop);
Remove an extraneous variable by changing the termination setup on the recursion.
130.11 Eugene van der Pijll Thu Aug 1 21:29:54 2002
-l sub a{($_,my$P)=@_;$P=~s/.//;$P||return$_;/$&/;my($y,$z,$o)=($-[0],$',$&);a($`,substr$P,0,$y),a($z,substr$P,$y),$o}print a@ARGV
131.09 Roberto Natella Sat Aug 3 15:16:46 2002
-l sub
n{local($_)=@_;return if!s/.//;@_=split$&,pop;$m=length$_[1];my$e=$&;my($n)=/(.{$m})$/;n($`,shift).n($n,pop).$e}print n@ARGV
131.10 Stanislav Svirid Wed Aug 7 16:58:08 2002
-l while(@ARGV){$i=pop;$_=pop;next if!$i&!$_;s/^.//;$i=~/$&/;push@ARGV,substr($_,0,$-[0]),$`,substr($_,$-[0]),$';$r="$&$r";}print$r
133.10 Michael Wrenn Mon Aug 5 20:23:12 2002
-l $_=pop;$p=pop;while(($m=$c)<26){@i=split//;$j=$i[$c++];1while index($p,$j)<index$p,$i[++$m];$c--if$m>$c;s/.{$m}/$&$j/;s/$j//}print
It took me a while to get past ALIEN/LENIA. A big misunderstanding. The good news is that I'm still in the Top 25.
134.09 Yanick Champoux Thu Aug 1 18:46:32 2002
-l sub
t{my$k=pop;($m)=grep$i[$_]eq$p[0],0..@i;if(@p&&$k>$m){my$z=shift@p;t($m);t($k);$_.=$z}}@$_=split'',pop for\@i,\@p;t(@i+1);print
Prettification
134.11 Markus Laire Mon Aug 5 15:22:08 2002
sub p{my($i,$p)=@_;"$p!$i"=~/(.)(.*)!(.*?)\1(.*)/||return;my$z=$1;my@x=($4,substr$p,1+length$3);p($3,$2).p(@x).$z}print p(@ARGV)."\n";
138.08 Keith Calvert Ivey Sun Aug 4 02:04:16 2002
-l sub'_{my($m,$n)=@_;$m=~s/.//||return;my$o=$&;my($p,$q)=split$o,$n;_(substr($m,0,length$p),$p)._(substr($m,length$p),$q).$o}print+_@ARGV
Somehow I don't think this is ever going to get down to a reasonable length, but at least it works (and this time I'm even submitting it in the right place).
138.14 Mtv Europe Thu Aug 1 05:32:13 2002
-l sub f{my($a,$b,@a,@b)=@_;$a=~/./;@b=$b=~/(.*)$&(.*)/;@a=$a=~/(.)(.{$+[1]})(.*)/;$a[0]&&f($a[1],$b[0]).f($a[2],$b[1]).$a[0]}print f@ARGV
first post :)
139.08 Phil Radden Fri Aug 2 19:41:17 2002
-l sub z{my($x,$y)=@_;my$t=substr$y,0,1;my($l,$r)=split$t,$x;return$x?z($l,substr$y,1,length$l).z($r,substr$y,-length$r).$t:""}print z@ARGV
140.09 James Harvey Thu Aug 1 18:51:50 2002
-l print z(@ARGV);sub z{my$p=pop or return;$p=~s/^.//;my$f=$&;my($j,$k)=split/$&/,pop;$a=substr$p,0,length$j,"";return z($j,$a).z($k,$p).$f}
oops, last one had a vi command stuck at the end...
141.09 Brad Jones Thu Aug 1 20:56:52 2002
-l sub z{my($y,$x,$w,$z)=split/$_[0]/,pop;$z=length$y;$w=z(@_[1..$z],$y)if$z;$w.=z(@_[$z+1..$#_],$x)if$x;$w.$_[0]}print z((split//,pop),pop);
Nuke extraneous variable.
141.12 Danny Rathjens Thu Aug 8 04:23:04 2002
-l sub f{my($i,@p)=@_;$i=~/$p[0]/;my($l,$r,$t,$j)=($`,$',$&,$-[0]);@p>2?f($l,@p[1..$j]).f($r,@p[$j+1..$#p]).$t:$l.$r.$t}print f pop,pop=~/./g
switched to use array to pass postorder, and using all the regex special vars, but their dynamic scoping doesn't work well in recursive function, ;(
144.09 Nik L Sat Aug 3 21:14:35 2002
-l sub c{my $j=shift@p;for($_[0]=~/(.*)$j(.*)/){next if/^$/;if(/^.$/){$o.=$_;shift@p;}else{c($_)}}$o.=$j}@p=split//,$ARGV[0];c($ARGV[1]);print$o
146.10 Danny Rathjens Thu Aug 8 03:22:27 2002
-l sub f{my$p=pop;my$t=substr$p,0,1;my($l,$r)=split/$t/,pop;$g=length$l;my($y,$z)=$p=~/.(.{$g})(.*)/;$p=~/../?f($l,$y).f($r,$z).$t:$p}print f@ARGV
doh, left multi-char var names in first one
149.09 Brad Jones Thu Aug 1 20:45:20 2002
-l sub z{my$z=pop;my($y,$x,$w,$v)=split/$_[0]/,$z;$v=length$y;$w=z(@_[1..$v],$y)if$v;$w.=z(@_[$v+1..$#_],$x)if$x;$w.$_[0]}print z((split//,pop),pop);
All that kvetching about how long 'length' is, and I left an extraneous one in there. Feh.
150.10 Erik Beatty Thu Aug 8 04:47:44 2002
$i=pop;$_[0]=pop;
while(@_){$p=pop@_;
if($i=~s/\w//){
 if($p=~/$&/){($&=~/$p/)?$a.=$p:push@_,$&,$',$`}
 else{$a.=$p;$i=$&.$i}}else{$a.=$p}
}print$a,$/
Just another idea I had at the last minute.. just not enough time to tweak with it...
154.11 Roberto Natella Fri Aug 2 17:43:02 2002
-l sub
n{local($_)=@_;return$_ if''eq$_;/./;pop=~/$&/;local($m,$n,$c,$d,$e)=(length$`,length$',$`,$',$&);n(/.(.{$m})/,$c).n(/(.{$n})$/,$d).$e}print n@ARGV
A sort of quick-sort :)
155.09 Danny Rathjens Thu Aug 8 03:05:35 2002
-l sub f{my$p=pop;my$t=substr$p,0,1;my($il,$ir)=split/$t/,pop;$g=length$il;my($pl,$pr)=$p=~/.(.{$g})(.*)/;$p=~/../?f($il,$pl).f($ir,$pr).$t:$p}print f@ARGV
Getting on the board at least, ;)
155.12 Michael Robinson Sun Aug 4 02:00:36 2002
sub q{my($p,$i)=@_;$p=~s/(.)//;$o=$1.$o;my($l,$r)=$i=~/(.*)$1(.*)/;$i=length($l)
;&q(substr($p,$i),$r)if$r;&q(substr($p,0,$i),$l)if$l;}&q(@ARGV);print"$o
"
156.09 Brad Jones Thu Aug 1 20:30:11 2002
-l sub z{my$z=pop;my($y,$x,$w,$v)=split/$_[0]/,$z;$v=length$y;$w=z(@_[1..$v],$y)if$v;$w.=z(@_[$v+1..$#_],$x)if length$x;$w.$_[0]}print z((split//,pop),pop);
Things I've learned so far from this: 'return' is optional, as are semicolons immediately in front of }. 'my' really _is_ necessary when you're recursing. Perl likes having a statement between the ':' and ';' in ?: constructs. When working on these problems, 'length' feels like the longest word in the English language.
156.11 Alistair McGlinchy Wed Aug 7 16:24:20 2002
-l sub t{my ($p,$i)=@_;my$f=substr$p,0,1,''or return;my($j,$k)=$i=~/(.*)$f(.*)/;$n=$j=~y///c;my($q,$r)=$p=~/(.{$n})(.*)/;t($q,$j).t($r,$k).$f}print t(@ARGV)
Urgh!!!
161.11 Markus Laire Mon Aug 5 14:04:17 2002
sub p{my($i,$p)=@_;return if!$p;$_[1]=~/(.)/;my$z=$1;$i=~/(.*?)$z(.*)/;my$x=$2;$l=$+[1];my$y=substr($p,$l+1);p($1,substr$p,1,$l).p($x,$y).$z}print p(@ARGV)."\n";
165.10 zImage Sat Aug 3 20:33:25 2002
-l sub p{return$_ if length($_=shift)<2;/^./;my($a,$o,$b)=pop=~/(.*)($&)(.*)/;my($c,$d)=$_=~/$o([$a?$a]*)([$b?$b]*)/;return p($c,$a).p($d,$b).$o}print p(shift,shift)
I don't think recursion is the way to go, but I can't think of any other way.
166.10 zImage Sat Aug 3 19:20:40 2002
-l sub p{$_=shift;return$_ if length$_<2;/^./;my($a,$o,$b)=pop=~/(.*)($&)(.*)/;my($c,$d)=$_=~/$o([$a?$a]*)([$b?$b]*)/;return p($c,$a).p($d,$b).$o}print p(shift,shift)
167.09 Ross Younger Thu Aug 1 22:50:03 2002
sub c{my($i,$p,$r,$x)=(pop||return,pop);$r=substr$p,0,1;$x=index$i,$r;c(substr($p,1,$x),substr($i,0,$x));c(substr($p,1+$x),substr($i,$x+1));$o.=$r}c pop,pop;print"$o
"
171.09 Brad Jones Thu Aug 1 19:58:26 2002
-l sub z{my$z=pop;my($y,$x,$w,$v)=split/$_[0]/,$z;$v=length $y;$w=($v)?z(@_[1..$v],$y):$y;$w.=length($x)?z(@_[$v+1..$#_],$x):$x;return$w.$_[0];}print z((split//,pop),pop);
First cut. There's got to be a better way to do this, but I don't see it right now.
171.10 zImage Sat Aug 3 17:13:47 2002
-l sub p{return $_[0]if length$_[0]<2;$_[0]=~/^./;my($a,$o,$b)=pop=~/(.*)($&)(.*)/;my($c,$d)=pop=~/$o([$a?$a]*)([$b?$b]*)/;return p($c,$a).p($d,$b).$o}print p(shift,shift)
183.11 zImage Sat Aug 3 16:07:00 2002
-l sub p{return $_[0]if length$_[0]<2;$_[0]=~/^./;my($a,$o,$b)=pop=~/(.*)($&)(.*)/;my($c,$d)=pop=~/$o([($a?$a:" "]*)([($b?$b:" "]*)/;return p($c,$a).p($d,$b).$o;}print p(shift,shift);
I see a lot of crufty spots, but I don't know how to optimize them :(
190.09 Oleg Fri Aug 2 17:00:53 2002
$p=pop;$i=pop;sub t{my$n=pop;$k.=$c=substr($p,$n,1);$d[$n]=1;map{$a=$_;map{$t=substr($p,$_,1);t($_)if$i=~/$c.*$t/&&!$a||$i=~/$t.*$c/&&$a and!$d[$_]}$n..length$p}0,1}t 0;print reverse($k)."
"
197.11 zImage Sat Aug 3 08:00:29 2002
-l sub p{return $_[0]if length$_[0]<2;$_[0]=~/^./;(my$a,my$o,my$b)=pop=~/(.*)($&)(.*)/;pop=~/$o([($a?$a:" "]*)([($b?$b:" "]*)/;(my$c,my$d)=($1,$2);return p($c,$a).p($d,$b).$o;}print p(shift,shift);
199.11 zImage Sat Aug 3 07:42:35 2002
-l sub p{return $_[0]if length($_[0])<2;$_[0]=~/^./;(my$a,my$o,my$b)=pop=~/(.*)($&)(.*)/;pop=~/$o([($a?$a:" "]*)([($b?$b:" "]*)/;(my$c,my$d)=($1,$2);return p($c,$a).p($d,$b).$o;}print p(shift,shift);
274.18 Yanick Champoux Thu Aug 1 16:58:32 2002
-l @i = split'',pop;
@p= split'',pop;

t( grep $in[$_]eq$p[0],0..@in  );
t( @i+1 );

sub t
{
        my $k = shift;
        my( $m) = grep $i[$_]eq$p[0],0..@i;
    return if !@p  or $k <= $m ;
        my $z=shift@p;
        t( $m );
        t( $k );
        $w.=$z;
}
print $w
Need I say it's only a first try?
275.09 Erik Beatty Thu Aug 1 23:30:23 2002
 $p=pop;$a{$k=0}=pop;while($p=~/(\w)/g){$p=~s/$+//;for(keys%a){if($a{$_}=~/$+/){$k=$_}}$a{$k}=~/$+/;$l=$`;$r=$';if($l){$a{$k}=~s/$l//;$a{$k*2+1}=$l}if($r){$a{$k}=~s/$r//;$a{$k*2+2}=$r}}p(0);print$/;sub p{my$p=pop;if($a{$p*2+1}){p($p*2+1)}if($a{$p*2+2}){p($p*2+2)}print$a{$p}}
gotta work on it some more... but wanted to get something in...
474.10 Kristen Thelen Sat Aug 3 07:22:32 2002
($f,$s)=@ARGV;$t=e($f,$s,length($f));p($t);print"
";sub e{my($i,$c,$d,$p,$r,$g,$h);my($k,$l,$m)=@_;return 0if($m<=0);$p->{V}=substr($l,0,1);$p->{L}=0;$p->{R}=0;return$p if($m==1);for($i=0;substr($k,$i,1)ne substr($l,0,1);$i++){}$c=$m-$i-1;$d=$m-$c-1;$g=substr($l,1);$r=$d+1;$h=substr($k,$r);if (!$g){$p->{L}=0;}else{$p->{L}=e($k,$g,$d);}if (!$h){$p->{R}=0;}else{$p->{R}=e($h,substr($l,$r),$c);}return $p}sub p{my($y)=@_;return unless $y;p($y->{L});p($y->{R});print $y->{V};}
Sorry for the long first submission.. This is more what I meant.
5667.12 Kristen Thelen Sat Aug 3 06:35:58 2002
-w # bintree - binary tree demo program


use strict;
my($f, $s, $i, $root, $two);
  
#print "\n\n-----------------\nProgram Start\n-----------------\n";

($f,$s)=@ARGV;

#print "length f=", length($f), "\n";
for ($i=0; $i<length($f); $i++)
{
#    print substr($f, $i, 1), " ";
    $two = substr($f, $i, 1);
#    insert($root, $two, $three);
}


#print "\nlength s=", length($s), "\n";
for ($i=0; $i<length($s); $i++)
{
    #print substr($s, $i, 1), " ";
    $two = substr($s, $i, 1);
#    insert($root, $two, $three);
}
#print "\n";


#insert($root, "a", 1);
#insert($root, "b", 1);
#insert($root, "c", 1);
#insert($root, "d", 1);


#print "In order: "; in_order($root); print "\n";
$root = buildtree($f, $s, length($f));

#print "Post order: "; post_order($root); print "\n";
post_order($root); print "\n";



#print "-----------------\nProgram End\n-----------------\n";


exit;
    

sub buildtree {
    #print "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
    my ($i, $lenright, $lenleft, $p, $r, $aa, $bb);
    my ($in, $pre, $len) = @_;
    if ($len<=0)
    {
^Ireturn undef;
    }
 
    $p->{VALUE}=substr($pre, 0, 1);
    #print "value=", substr($pre, 0, 1), "\n";
    $p->{LEFT}=undef;
    $p->{RIGHT}=undef;
    
    if ($len == 1)
    {
^Ireturn $p;
    }
    
    for ($i=0; substr($in, $i, 1) ne substr($pre, 0, 1); $i++)
    {
    }
    
    $lenright=$len-$i-1;
    $lenleft=$len-$lenright-1;
    #print "i=", $i, "\n";
    #print "lenleft=", $lenleft, "\n";
    #print "lenright=", $lenright, "\n";
    #print "substr1=", 
    $aa=substr($pre, 1);
    if (!$aa)
    {
^I#print ("AA NULL\n");
    }
    
    #print "substr2=", 
    $bb=substr($in, $lenleft+1);

    if (!$aa)
    {
^I$p->{LEFT}=undef;
    }
    else
    {
^I#print "LEFT LEFT LEFT LEFT LEFT\n";
^I$p->{LEFT}=buildtree($in, substr($pre, 1), $lenleft);
    }
    $r=$lenleft+1;

    if (!$bb)
    {
^I$p->{RIGHT}=undef;
    }
    else
    {
^I$p->{RIGHT}=buildtree(substr($in, $r), substr($pre, $r),  $lenright);
    }
    return $p;
}
#      insert($root, $pre[0]);
#      if ($len==1)
#  ^Ireturn p;
#      for ($i=0; $in[$i]!=$pre[0]; $i++);
#      $lenright=$len-$i-1;
#      $lenleft= $len-$lenright-1;
#      insert(p->left, buildtree(in, pre+1, lenleft));
#      insert(p->left, buildtree(in, pre+1, lenleft));
#      return p;
#  }

# $_[0] is the inorder string
# $_[1] is the preorder string
# $_[2] is the length of the string

#  sub buildtree {
#      my ($i, $lenright, $lenleft, $p);
#      insert($root, $pre[0]);
#      if ($len==1)
#  ^Ireturn p;
#      for ($i=0; $in[$i]!=$pre[0]; $i++);
#      $lenright=$len-$i-1;
#      $lenleft= $len-$lenright-1;
#      insert(p->left, buildtree(in, pre+1, lenleft));
#      insert(p->left, buildtree(in, pre+1, lenleft));
#      return p;
#  }
     
    


#  use strict;
#  my($root, $n);

#  # first generate 20 random inserts
#  while ($n++ < 20) { insert($root, int(rand(1000)))}

#  # now dump out the tree all three ways
#  print "Pre order:  ";  pre_order($root);  print "\n";
#  print "In order:   ";  in_order($root);   print "\n";
#  print "Post order: ";  post_order($root); print "\n";

#  # prompt until EOF
#  for (print "Search? "; <>; print "Search? ") { 
#      chomp;
#      my $found = search($root, $_);
#      if ($found) { print "Found $_ at $found, $found->{VALUE}\n" }
#      else        { print "No $_ in tree\n" }
#  }

#  exit;

#########################################

# insert given value into proper point of
# provided tree.  If no tree provided, 
# use implicit pass by reference aspect of @_
# to fill one in for our caller.
sub insert {
    my($tree, $value, $position) = @_;  #position 0 means insert to left 1 right

    my($new);

#    $position=$three;
    print "value=", $value, "\n";
    print "position=", $position, "\n";

    unless ($tree) {
        $tree = {};                         # allocate new node
        $tree->{VALUE}  = $value;
        $tree->{LEFT}   = undef;
        $tree->{RIGHT}  = undef;
        $_[0] = $tree;              # $_[0] is reference param!
        return;
    }
    if ($position == 0) 
    {
^I$new={};
        $new->{VALUE}  = $value;
        $new->{LEFT}  = $tree;
        $tree->{RIGHT}  = undef;

^I#insert($tree->{LEFT},  $value, $position);
    }
    elsif ($position == 1) { 
^I$new={};
        $new->{VALUE}  = $value;
        $new->{LEFT}  = undef;
        $tree->{RIGHT}  = $tree;
^I#insert($tree->{RIGHT}, $value, $position);
    }
    else                            { warn "dup insert of $value\n"  }
                                    # XXX: no dups
}

# recurse on left child, 
# then show current value, 
# then recurse on right child.
sub in_order {
    my($tree) = @_;
    return unless $tree;
    in_order($tree->{LEFT});
    print $tree->{VALUE}, " ";
    in_order($tree->{RIGHT});
}

# show current value, 
# then recurse on left child, 
# then recurse on right child.
sub pre_order {
    my($tree) = @_;
    return unless $tree;
    print $tree->{VALUE}, " ";
    pre_order($tree->{LEFT});
    pre_order($tree->{RIGHT});
}

# recurse on left child, 
# then recurse on right child,
# then show current value. 
sub post_order {
    my($tree) = @_;
    return unless $tree;
    post_order($tree->{LEFT});
    post_order($tree->{RIGHT});
    print $tree->{VALUE};
}

# find out whether provided value is in the tree.
# if so, return the node at which the value was found.
# cut down search time by only looking in the correct
# branch, based on current value.
sub search {
    my($tree, $value) = @_;
    return unless $tree;
    if ($tree->{VALUE} == $value) {
        return $tree;
    }
    search($tree->{ ($value < $tree->{VALUE}) ? "LEFT" : "RIGHT"}, $value)
}
First Try

Artistic/Unorthodox

ScoreGolferSubmit TimeCode
209.10 pom Mon Aug 5 09:18:36 2002
($_,$i)=@ARGV;push(Q,$i);while(@Q){if(/(.)/&&($x=index($q=$Q[$#Q],$1))>=0){$l=length($q)-1;push(Q,substr($q,$x+1,$l-$x))if$x<$l;push(Q,substr($q,0,$x))if$x;s/(.)//;push(O,$1);}else{pop@Q;print pop@O;}}print$/;
Ah, the joys of perl1! No recursion and very limited regular expressions (as compared to what we have now) lead to this quite pedestrian solution. The interpreter alos caused some trouble, making the final (but working) solution somewhat longer...

Rejected

ScoreGolferSubmit TimeCode
48.12 Markus Laire Thu Aug 8 02:35:05 2002
-l $_*=$z%9e9,/0*$/,$z=$`for++$z..pop;print$z%10
looks like a solution for factorial actually
54.12 Ala Qumsieh Thu Aug 8 02:49:45 2002
$_=pop;$ARGV[0]=~/[$_]/,$/=$&.$/,s/$&//while$_;print$/
gives FED for DEF EDF, instead of the correct EFD
60.10 Josef Drexler Mon Aug 5 04:53:17 2002
$_||=pop;$ARGV[0]=~/./g;s/$&/ /;do$0for split;print$&,$/x!$^S
This works on Win32, not on Linux. I think it's because of $^S but I don't know whether that disqualifies it. It's a bug in Perl 5.6.1, but not a consistent one...
70.11 Bass Sun Aug 4 20:29:20 2002
-l @~=sort{$ARGV[0]!~/$b.*$a/|!$b&&($_.=$b,$b='',-1)}pop=~/./g,z;print
only works for strings of length 5 or shorter. sort does not use insertion sort for arrays larger than that :-)
86.14 Markus Laire Tue Aug 6 17:56:09 2002
($_=pop)&&(/~/?$x.=$`:($ARGV[0]=~/./g,/$&/,push@ARGV,"$&~",$',$`))while$=--;print$x,$/
88.29 gimbo Sat Aug 3 12:07:38 2002
-l s//@ARGV/;$=+=26*s/^(.)(.{$=})(.*) (.{$=})\1(.*)/$2 $4
$3 $5
$1/mwhile$=--;print/\w/g
128.11 Eugene van der Pijll Fri Aug 2 18:14:18 2002
-l sub a{($_,my$I)=@_;s/.//;my$P=$_ or return$I;my($z,$x,$y)=($&,split$&,$I);a(/[ $x]+/g,$x),a($P=~/[ $y]+/g,$y),$z}print a@ARGV
129.12 Jasper McCrea Fri Aug 2 17:18:15 2002
-l sub e{($_,$p)=@_;my($t)=$p=~/./g;my($y,$r)=split$t;($d=$y)=~s//./g;$p=~/.($d)/;my$l=$';$t&&(e($y,$1),e($r,$l),$t)}print e@ARGV
there must be a purely regex way to do this, but this will do for a 'first' attempt
143.09 James Harvey Thu Aug 1 16:12:02 2002
-l print z(@ARGV);sub z{my$p=pop or return;$p=~s/^.//;my$f=$&;my($j,$k)=split/$&/,pop;$a=substr$p,0,length$j,"";return z($j,$a).z($k,$p).$f:w
}
217.09 Artem Baranov Sun Aug 4 15:23:57 2002
$r=pop;$i=pop;sub 
l{length$_[0]};push@s,$i;@p=split(//,$r);for$i(0..$#p){while(l($_=pop@s)==1){print$_}/(.*)$p[$i](.*)/;if(l($1.$2)!=0){push@s,$p[$i]}else{push@s,$_}push@s,$2if(l($2)!=0);push@s,$1if(l($1)!=0)}print$/
217.09 Artem Baranov Mon Aug 5 07:26:27 2002
$i=pop;$r=pop;sub l{length$_[0]};
push@s,$i;@p=split(//,$r);for$i(0..$#p){while(l($_=pop@s)==1){print$_}/(.*)$p[$i](.*)/;if(l($1.$2)!=0){push@s,$p[$i]}else{push@s,$_}push@s,$2if(l($2)!=0);push@s,$1if(l($1)!=0)}print$/
219.09 Artem Baranov Sun Aug 4 14:49:05 2002
$r=pop;$i=pop;sub l{length$_[0]};push@s,$i;@p=split(//,$r);
for$i(0..$#p){while(l($_=pop@s)==1){print$_}/(.*)$p[$i](.*)/;
if(l($1.$2)!=0){push@s,$p[$i]}else{push@s,$_}
push@s,$2if(l($2)!=0);push@s,$1if(l($1)!=0)}print$/
234.10 Artem Baranov Sun Aug 4 12:05:56 2002
$r=pop;$i=pop;sub l{length($_[0])}
push(@s,$i);@p=split(//,$r);
for$i(0..$#p){while(l($_=pop(@s))==1){print$_}/(.*)$p[$i](.*)/;
if(l($1.$2)!=0){push(@s,$p[$i]);}else{push(@s,$_)}
push(@s,$2)if(l($2)!=0);push(@s,$1)if(l($1)!=0)}print$/