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.
#!perl s~~ @ARGV~;print$1until!s~(.)(?= |(.).+\2.*\1)~~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
#!perl 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
#!perl s// @ARGV/;print$1until!s~(.)( |(.).+\3.*\1)~$2~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.!
#!perl s// @ARGV/;print$1until!s~(.)(?= |(.).+\2.*\1)~~s |
My fourth solution, and I've used three completely different algorithms.
#!perl print s~(.)( |(.).+\3.*\1)~$2~?$1:$/while$2||s//@ARGV/ |
I thought \X in place of \C would work, but it gives me a seg fault!
#!perl -l $_="@ARGV";$}=$1.$},s~$1~ ~gwhile/(.)\C+\1.* *$/;print$} |
#!perl -l $_=pop;$ARGV[0]=~/[$&]/,$}=$&.$},s~$&~ ~while/.+ *$/;print$} |
16 strokes just to put a \n in the right place.
#!perl $_|=pop;$z|=pop;/[$z]/;$}+=$z=~/$&/;do$0if$z=$`;do$0if$z=$';--$}or$\=$/;print$& |