.03 tiebreak improvement
#!perl -p
s//m/;y/ //dwhile
s^(([+-])M(?![*/])|([*/])M|m(-*\d+))(?{push
_,$+})|.M\)^M^||s/m(.)/$+m/i;s/M/@_/
|
that's y/
//... (actually, I think the copy/paste problem is on my end :( )
nice...
#!perl -p s//m/;y/ //dwhile s^([+-])M(?![*/])|([*/])M|m(-*\d+)|.M\)^~$+&&push _,$+;M^e||s/m(.)/$+m/i;s/M/@_/ |
the y/// contains both a
and a . Some tiebreak improvement :)
hmm .. closing in on double digits
#!perl -p y/ //d+s//m/;1while s^([+-])M(?![*/])|([*/])M|m(-*\d+)|.M\)^~$+&&push a,$+;M^e||s/m(.)/$+m/i+s/M/@a/ |
That's y/
//d at the start. 7:57 for v5 on my 200Mhz, should be fine on a 600 :)
#!perl -p y/ //d;s//m/;1while s!([+-])M(?=$|[)+-])|([*/])M|m(-?\d+)|.M\)!~$+&&push@a,$+;M!e||s/m(.)/$+m/i;s/M/@a/ |
that y/// has both a space and a hard tab in it y/ \t//d
#!perl -pi])M(?=$|[) y/ //d;s//m/;1while s/\(M\)/M/|s!([^($^I+-])|([*/$^I*/])|m(-?\d+)!push@a,$+;M!e||s/M(.)/$+m/i;s/M/@a/ |
My first ever entry to "Artistic". It's a classical recursive descent, and I think it looks quite elegant and even pretty. It has an interesting mechanism for local storage in the recursive routines :) Also, if the lines are combined into one line, it's a 137, one shorter than the original BoB!
pretty :)
#!perl -p
sub o{print$"x$|++,shift}
sub f{s/^-*\d+//?o$&:e(s/.//)+s/.//}
sub t{f;o$&x1,f while s+^[*/]++}
sub e{t;o$&x1,t while s/^[+-]//}
e y/ //d
|
My first ever entry to "Artistic". It's a classical recursive descent, and I think it looks quite elegant and even pretty. It has an interesting mechanism for local storage in the recursive routines :) Also, if the lines are combined into one line, it's a 137, one shorter than the original BoB!
#!perl -p
sub o{print$"x$|++,shift}
sub f{s/^-*\d+//?o$&:e(s/.//)+s/.//}
sub t{f;o$&x1,f while s+^[*/]++}
sub e{t;o$&x1,t while s/^[+-]//}
e y/ //d
|
Fails on 1 - -
2.
#!perl -p s//M/;y/ //d;s!([)\d])-!$1=!g;1while s/\(M\)/M/|s!([^(])M(?=$|[=+)])|([*/])M(?=$|[*/)])|M(-?\d+)!push@a,$+;M!e||s/M(.)/$1M/;s/M/@a/;y/=/-/ |
resubmitted. That y/ //d at the beginning contains both a space and a tab. Please make sure your copy/paste is not changing it. This script passes version 3 of the test program.
#!perl -p y/ //d;s//M/;s!([)\d])-!$1=!g;1while s/\(M\)/M/|s!([^(])M(?=$|[=+)])|([*/])M(?=$|[*/)])|M(-?\d+)!push@a,$+;M!e||s/M(.)/$1M/;s/M/@a/;y/=/-/ |
to handle (-1+2)
thanks for the new test
#!perl -p0 s//M/;s!([-M+*/(])-(?=\d)!$1=!g;s/\s//while s/\(M\)/M/|s!([-+*/])M(?=[-+)]|$)|([*/])M(?=[*/)]|$)|M(=?\d+)!push@a,$+;M!e||s/M(.)/$1M/ ;$_="@a ";y/=/-/ |
just to get on the board, so I don't have to go through that infinite selection list :)
#!perl -p0 s//M/;s/\s+//g;s!([-M+*/])-(?=\d)!$1=!g;1while s/M(=?\d+)/push@a,$1;M/e |s/\(M\)/M/ ||s!([-+*/])M(?=[-+)]|$)|([*/])M(?=[*/)]|$)!push@a,$+;M!e ||s/M(.)/$1M/ ;$_="@a ";y/=/-/ |