|
| Back to Perl Golf |
Referee comments are in italics. Blue rows denote golfer's best solution. Red text denotes special characters.
| Score | Golfer | Submit Time | Code |
| 98.22 | Eugene van der Pijll | Thu Sep 5 22:19:40 2002 | -p sub
w{s/
([@_^+-])(.*)/ $2 $1/g}sub
f{s/\(([^()]+)\)/f($_=$+)/e?&f:w~w;$_}f
s/\s//g/s/\d+/$&
/g |
| 99.24 | BoB (Best of Breed - referees) | Thu Sep 5 22:16:57 2002 | -p sub
w{s/
([@_^+-])(.*)/ $2 $1/g}sub
f{s/\(([^()]+)\)/f($_=$1)/e&&&f;w~w;$_}s/\s//g+s/\d+/$&
/g+f |
| optimize tiebreak | |||
| 99.26 | Eugene van der Pijll | Thu Sep 5 22:04:21 2002 | -p s/\s//g;s/\d+/$&
/g;sub
w{s/
([@_^+-])(.*)/ $2 $1/g}sub
f{s/\(([^()]+)\)/f($_=$1)/e&&&f;w~w;$_}f |
| Into the double digits... | |||
| 100.34 | BoB (Best of Breed - referees) | Thu Sep 5 21:26:40 2002 | -p s//m/;y/ ^I//dwhile s^[+-]M(?![*/])|[*/]M|m-*\d+|.M\)^M^?push _,$&=~/[*-9]+/g:s/m(.)/$+m/i;s/M/@_/ |
| push a /g match of $& instead of $+ | |||
| 101.25 | Eugene van der Pijll | Thu Sep 5 22:03:22 2002 | -p s/\s//g;s/\d+/$&
/g;sub
w{s/
([@_^+-])(.*)/ $2 $1/g}sub
f{s/\(([^()]+)\)/f($_=$1)/e&&&f;w;w 7;$_}f |
| 101.31 | BoB (Best of Breed - referees) | Thu Sep 5 20:56:07 2002 | -p s//m/;y/ ^I//dwhile s^([+-])M(?![*/])|([*/])M|m(-*\d+)|.M\)^M^?~$+?push _,$+:1:s/m(.)/$+m/i;s/M/@_/ |
| Rick's 102, with the push moved outside the s///. | |||
| 102.23 | BoB (Best of Breed - referees) | Thu Sep 5 18:27:42 2002 | -p sub
w{s/
([@_^+-])(.*)/ $2 $1/}sub
f{s-\(([^()]+)\)-f($_=$1)-e||w||w(7)?&f:$_}s/\s//g+s/\d+/$&
/g+f
|
| remove local from eugene's 107, reorganize a bit to improve tie. | |||
| 102.26 | Eugene van der Pijll | Thu Sep 5 21:41:11 2002 | -p s/\s//g;s/\d+/$&
/g;sub
w{s/
([@_^+-])(.*)/ $2 $1/}sub
f{s-\(([^()]+)\)-$_=$1;&f-e||w||w(7)?&f:$_}f |
| Of course. The true&tested method of "Can't possibly work, let's try it anyway." | |||
| 102.30 | Rick Klement | Sat Sep 7 19:22:19 2002 | -p s//m/;y/ ^I//dwhile
s^(([+-])M(?![*/])|([*/])M|m(-*\d+))(?{push
_,$+})|.M\)^M^||s/m(.)/$+m/i;s/M/@_/ |
| .03 tiebreak improvement | |||
| 102.33 | Rick Klement | Thu Sep 5 14:18:47 2002 | -p s//m/;y/ ^I//dwhile s^([+-])M(?![*/])|([*/])M|m(-*\d+)|.M\)^~$+&&push _,$+;M^e||s/m(.)/$+m/i;s/M/@_/ |
| that's y/ nice... | |||
| 103.23 | BoB (Best of Breed - referees) | Tue Sep 3 21:18:20 2002 | -p y/ ^I//d+s//^I/;~$+&&push a,$+while s^([+-]) (?![*/])|([*/]) |^I(-*\d+)|. \)^ ^||s/\s(.)()/$1^I/;s/ /@a/ |
| Heh, heh | |||
| 103.30 | BoB (Best of Breed - referees) | Tue Sep 3 19:38:22 2002 | -p y/ ^I//d+s//m/;~$+&&push a,$+while s^([+-])M(?![*/])|([*/])M|m(-*\d+)|.M\)^M^||s/m(.)()/$1m/i+s/M/@a/ |
| Rick's 104.31, slightly reorganized | |||
| 103.33 | Ton Hospel | Sun Sep 8 03:48:17 2002 | -Xlp sub
c{($|--&&/\s/*s///g%/^./+/^-*\d+/?$&:c()).pop.($|--?/^[+-]/:s///
x/^[*\/]/and$".c(" $&"))}$_=c |
| 103.34 | Ton Hospel | Sun Sep 8 03:05:03 2002 | -Xlp sub
c{($|--&&s///g%/^./+/^-*\d+/?$&:c()).pop.($|--?/^[+-]/:s///
x/^[*\/]/and$".c(" $&"))}/\s/;$_=c |
| 103.61 | Ton Hospel | Sun Sep 8 02:56:36 2002 | -Xlp sub c{($|--&&s///g%/^./+/^-?\d+/?$&:c()).pop.($|--?/^[+-]/:s/// x/^[*\/]/and$".c(" $&"))}/\s/;$_=c |
| 104.25 | Ton Hospel | Thu Sep 5 01:18:05 2002 | -p sub
c{$|--&&s///-/./+/^-*\d+/?$&+0:c(),@_,($|--?/^[+-]/:s///
x/^[*\/]/and$",c(" $&"))}y/ ^I//d;print
c |
| since i can't seem to find anything big, let's think small | |||
| 104.26 | Ton Hospel | Wed Sep 4 22:45:06 2002 | -p sub
c{$|--&&s///%/./+/^-*\d+/?$&+0:c(),@_,($|--?/^[+-]/:s///
x/^[*\/]/and$",c(" $&"))}y/ ^I//d;print
c |
| almost forgot one more line | |||
| 104.30 | Ton Hospel | Wed Sep 4 22:40:50 2002 | -p sub
c{$|--&&s///%/./+/^-*\d+/?$&+0:c(),@_,($|--?/^[+-]/:s///
x/^[*\/]/and$",c(" $&"))}y/ ^I//d;print c |
| Actually reading the tiebreaker code can be useful | |||
| 104.31 | Rick Klement | Tue Sep 3 15:20:03 2002 | -p y/ ^I//d+s//m/;1while s^([+-])M(?![*/])|([*/])M|m(-*\d+)|.M\)^~$+&&push a,$+;M^e||s/m(.)/$+m/i+s/M/@a/ |
| the y/// contains both a hmm .. closing in on double digits | |||
| 104.57 | Ton Hospel | Wed Sep 4 17:17:57 2002 | -p sub c{$|--&&s///-/./+/^-?\d+/?$&+0:c(),@_,($|--?/^[+-]/:s/// x/^[*\/]/and$",c(" $&"))}y/ ^I//d;print c |
| another way to handle the \n | |||
| 104.61 | Ton Hospel | Wed Sep 4 00:24:09 2002 | -Xlp sub c{($|--&&s///%/./+/^-?\d+/?$&:c()).pop.($|--?/^[+-]/:s/// x/^[*\/]/and$".c(" $&"))}s/\s//g;$_=c |
| Back to a string representation | |||
| 105.62 | Ton Hospel | Wed Sep 4 00:10:41 2002 | -lp sub c{$|--&&s///%/./+/^-?\d+/?"$&":c(),@_,(--$|?s///*/^[*\/]/:/^[+-]/)?c("$&"):()}s/\s//g;$_="@{[c]}" |
| goodbye overload ! | |||
| 106.34 | BoB (Best of Breed - referees) | Tue Sep 3 11:58:24 2002 | -p y/^I //d;s//m/;1while s!([+-])M(?=[ )+-])|([*/])M|m(-?\d+)|.M\)!~$+&&push@a,$+;M!e||s/m(.)/$+m/i;s/M/@a/ |
| Rick's solution with a hard-linebreak inside the character group, instead of a $| outside it. | |||
| 107.29 | Eugene van der Pijll | Thu Sep 5 17:55:59 2002 | -p s/\s//g;s/\d+/$&
/g;sub
w{s/
([@_^+-])(.*)/ $2 $1/}sub
f{s-\(([^()]+)\)-local$_=$1;&f-e||w||w(7)?&f:$_}f |
| 107.44 | BoB (Best of Breed - referees) | Tue Sep 3 05:01:50 2002 | -pibless[s)$) y/ ^I//d;s/(?<!\)|\d)-*\d+/($^I $&)])/g;s/.?/"use
overload
'$&',sub{$^I $&)]}"/gee;eval$`;s///
|
| Ton's solution with the tiebreaker improved beyond Rick's solution by applying linebreaks and changing '!' delimiters to ')'. | |||
| 107.46 | Rick Klement | Mon Sep 2 13:45:07 2002 | -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/ | |||
| 107.74 | Ton Hospel | Mon Sep 2 23:26:19 2002 | -pibless[s!$! y/ ^I//d;s/(?<!\)|\d)-*\d+/($^I $&!])/g;s/.?/"use overload '$&',sub{$^I $&!]}"/gee;eval$`;s/// |
| flog! flog! | |||
| 108.30 | Eugene van der Pijll | Thu Sep 5 17:52:27 2002 | -p s/\s//g;s/\d+/$&
/g;sub
w{s-
([@_*/])(.*)- $2 $1-}sub
f{(s-\(([^()]+)\)-local$_=$1;&f-e||w||w"^")?&f:$_}f
|
| 108.61 | Ton Hospel | Tue Sep 3 23:33:32 2002 | -lp sub c{--$|?c():s///%/./+/^-?\d+/?"$&":c(),@_,(--$|?s///*/^[*\/]/:/^[+-]/)?c("$&"):()}s/\s//g;$_="@{[c]}" |
| grand unification | |||
| 109.51 | pom | Sat Sep 7 10:01:20 2002 | -p y/ ^I//d;s/\b\D/x$&/g;s--$_=$1;s// $2 $1/while/x(.)(\PL+)/+/x([*\/])(\PL+)/;$_-ewhile/(.+)x/+/\(([^()]+)\)/ |
| 109.51 | Alexey Rudenko | Fri Sep 6 17:26:41 2002 | -lp $p=qr'(([^() ]|\(( |(??{$p}))*\))+)';s/\s//g;s//$1 $3 $2/while/(.*)([*\/])$p/|/(.*[\d)])([-+])$p/;y/()//d |
| 109.78 | Ton Hospel | Mon Sep 2 23:05:52 2002 | -p y/ ^I//d;s#(?<!\)|\d)-?\d+#(bless[s!\$! $&!])#g;s/.?/"use overload '$&',sub{s!! $&!;shift}"/gee;eval$`;s/// |
| Still haven't flogged this horse to death | |||
| 110.36 | Eugene van der Pijll | Thu Sep 5 17:06:53 2002 | -p s/\s+//g;s/\d+/$&
/g;sub w{s#
([@_*/])(.*)# $2 $1#}sub
f{(s#\(([^()]+)\)#local$_=$1;&f#e||w||w"-+")?&f:$_}f |
| 110.83 | Ton Hospel | Mon Sep 2 10:19:58 2002 | -lp s/\s//g;s#(?<!\)|\d)-?\d+#(bless[s!\$!$& !])#g;s/.?/"use overload '$&',sub{s!!$& !;shift}"/gee;eval$`;chop |
| the code is now completely free of the list of operators, so it will work for the full perl operator set | |||
| 112.37 | Eugene van der Pijll | Thu Sep 5 16:34:33 2002 | -p s/\s+//g;s/\d+/$&
/g;sub w{s#
([@_*/])(.*)# $2 $1#}sub
f{1while s#\(([^()]+)\)#local$_=$1;&f#e||w||w"-+";$_}f |
| 112.63 | Michael Thelen | Sat Sep 7 20:01:19 2002 | -lp y/()^I /^I_/d+s@^I|(?<=\w)\D@($"=" $&$\"")=~s#_(.*?)^I|(\S)([ */${":"x/\G[+-]/}]*)#$2 #;$+@eg;$_.=$";y/ //s+chop |
| Yet another stroke... today is a good day. Went back to using $" to avoid having to use /s or \C in the inner regex. | |||
| 113.28 | Michael Thelen | Sat Sep 7 19:55:24 2002 | -lp y/()^I /^I_/d+s@^I|(?<=\w)\D@($/="
$&$/")=~s#_(\C*?)^I|(\S)([
*/${":"x/\G[+-]/}]*)#$2
#;$+@eg;$_.=$/;y/
/ /s+chop |
| Continuing with the theme of absolute obfuscation... ')' is now replaced by '_' to make the use of \w possible. | |||
| 114.68 | Ton Hospel | Tue Sep 3 22:06:02 2002 | -lp sub a{join$",f(),@_,/^[+-]/?a("$&"):()}sub f{s///;/./;/^-?\d+/?"$&":a,@_,s///*m!^[*/]!?f("$&"):()}s/\s//g;$_=a |
| mm, recursive descent is running out of breath | |||
| 114.77 | Ton Hospel | Mon Sep 2 03:28:11 2002 | -lp s/\s//g;s#(^|[*-/(])(-?\d+)#$1(bless[s!\$!$2 !])#g;s/.?/"use overload '$&',sub{s!!$& !;shift}"/gee;eval$`;chop |
| 115.26 | Michael Thelen | Sat Sep 7 19:41:05 2002 | -lp y/)( ^I/ ^I/d+s@^I|(?<=\d| )\D@($/="
$&$/")=~s# (.*?)^I|(\S)([
*/${":"x/\G[+-]/}]*)#$2
#s;$+@eg;$_.=$/;y/
/ /s+chop |
| How absolutely confusing! Replacing parens with whitespace makes this probably the most obfuscated program I've ever written. | |||
| 115.55 | pom | Fri Sep 6 22:35:18 2002 | -p y/ ^I//d;s/\b/x/g;s~~$_=$1;s/x([$1])(-?)x(\PL+)/ $2$3 $1/while/x(\D)/|/x([*\/])/;$_~ewhile/x(.+)x/|/\(([^()]+)\)/ |
| 115.73 | Ton Hospel | Mon Sep 2 03:16:10 2002 | -p s#(^|[*-/(])\s*(-?)\s*(\d+)#$1(bless[s!\$! $2$3!])#g;s/.?/"use overload '$&',sub{s!! $&!;shift}"/gee;eval$`;s/// |
| Sigh. Sacrifise more characters | |||
| 116.27 | Qingning Huo | Sat Sep 7 22:59:34 2002 | -p s/\s//g/s/(?<!\)|\d)-?\d+/ $&/g;1while s/\(\)//||s# (-?\d+)|(?![-+][*/])([^(])(?! |\()|(.)$##&&push@0,$+;$_="@0 " |
| 116.28 | Qingning Huo | Sat Sep 7 22:46:05 2002 | -p s/\s//g;s/(?<!\)|\d)-?\d+/ $&/g;1while s/\(\)//||s# (-?\d+)|(?![-+][*/])([^(])(?! |\()|(.)$##&&push@0,$+;$_="@0 " |
| 116.48 | Rick Klement | Mon Sep 2 00:27:49 2002 | -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/ |
| that y/// has both a space and a hard tab in it y/ \t//d | |||
| 116.48 | Jeff Moore | Sat Sep 7 02:51:20 2002 | -p use
overload
nomethod,sub{bless[(map"@$_",@_[0,1]),pop]};y/ ^I//d;s/(?<!\d|\))-*\d+/bless(['$&'])/g;$_="@{+eval}
"
|
| 116.54 | Jeff Moore | Sat Sep 7 02:19:55 2002 | -pl use
overload
nomethod,sub{bless[(map"@$_",@_[0,1]),pop]};y/ ^I//d;s/(?<!\d|\))-*\d+/bless(['$&'])/g;$_="@{+eval}"
|
| 116.65 | Stephen Turner | Mon Sep 2 20:16:09 2002 | -pl use
overload'0+',sub{"@{$_[0]}"},nomethod,sub{bless\@_};y/ ^I//d+s/(?<![\d)])-?\d+/(bless["$&"])/g;$_=eval;y/ //s
|
| Just a better tie breaker. | |||
| 116.66 | Stephen Turner | Mon Sep 2 14:09:12 2002 | -pl use
overload'""',sub{"@{$_[0]}"},nomethod,sub{bless\@_};y/ ^I//d+s/(?<![\d)])-?\d+/(bless["$&"])/g;$_=eval;y/ //s
|
| One shot worse than my 115.47 solution, but shouldn't use so much memory or time! Sorry about the erronous rejection. | |||
| 117.26 | Qingning Huo | Sat Sep 7 22:24:40 2002 | -p y/ ^I//d;s/(?<!\)|\d)-?\d+/ $&/g;1while s/\(\)//||s# (-?\d+)|(?![-+][*/])([^(])(?=[^( ])|(.)$##&&push@0,$+;$_="@0 " |
| 117.52 | Jeff Moore | Fri Sep 6 23:48:09 2002 | -pl use
overload
nomethod,sub{bless["$_[0][0] $_[1][0] ".pop]};y/ ^I//d;s/(?<!\d|\))-*\d+/bless(['$&'])/g;$_=eval->[0]
|
| 117.64 | Michael Thelen | Sat Sep 7 05:42:38 2002 | -lp y/ ^I//d+s@\(|(?<=[\d)])\D@($"=" $&$\"")=~s!\)(.*?)\(|([^ (])([ */${':'x/\G[+-]/}]*)!$2 !;$+@eg;$_.=$";y/ //s+chop |
| Simple removal of an unnecessary space character. Now I just need to find the other 20 unnecessary characters. | |||
| 117.66 | Jeff Moore | Thu Sep 5 22:21:07 2002 | -pl use
overload'""',sub{$_[0][0]},nomethod,sub{bless["@_"]};y/ ^I//d;s/(?<!\d|\))-*\d+/bless(['$&'])/g;$_=eval;y/ //s
|
| 118.45 | Stephen Turner | Sun Sep 1 20:16:22 2002 | -p sub
n{bless\@_}use
overload
nomethod,sub{n@{$_[0]},@{$_[1]},pop};y/ ^I//d+s/(?<![\d)])-?\d+/(n"$&")/g;$_="@{eval
}
" |
| Save a lot of strokes in the constructor by using arrays instead of scalars as the objects. WARNING: Uses a lot of memory for the final test. It does complete within the memory and speed constraints though. | |||
| 118.54 | Alexey Rudenko | Wed Sep 4 11:14:24 2002 | -lp $p=qr'-?\d+|\(([^()]|(??{$p}))*\)';s/\s//g;s// $2 $1/while/([*\/])($p)/|/(?<=[-+\d)])([-+])($p([*\/]$p)*)/;y/()//d |
| 118.57 | Alain "TopMach" Dupuis | Sun Sep 8 02:32:16 2002 | -p y/ ^I//d;sub t{$_=pop;for$+('*/','+-'){1while s/(\S)([$+])(-?(\d+| .)*)/$1 $3 $2/}$_}1while s/\(([^()]+)\)/t$1/e;t$_ |
| 118.64 | Michael Thelen | Sat Sep 7 00:31:12 2002 | -lp y/ ^I//d+s@\(|(?<=[\d)])\D@($"=" $& $\"")=~s!\)(.*?)\(|([^ (])([ */${':'x/\G[+-]/}]*)!$2 !;$+@eg;$_.=$";y/ //s+chop |
| Who knew you could interpolate $" as "$\""? Strange... | |||
| 119.58 | Michael Thelen | Fri Sep 6 20:53:44 2002 | -lp y/ ^I//d+s@\(|(?<=[\d)])\D@($*=" $& $*")=~s!\)(.*?)\(|([^ (])([ */${':'x/\G[+-]/}]*)!$2 !;$+@eg;$_.=$*;y/ //s+s/ $// |
| Just a tiebreak improvement, but hey, every little bit helps. | |||
| 119.59 | Alain "TopMach" Dupuis | Sun Sep 8 01:40:32 2002 | -lp s/\s//g;sub t{$_=pop;for$+('*/','+-'){1while s/(\S)([$+])(-?(\d+| .)*)/$1 $3 $2/}$_}1while s/\(([^()]+)\)/t$1/e;t$_ |
| 119.61 | Michael Thelen | Thu Sep 5 23:01:23 2002 | -lp y/ ^I//d+s@\(|(?<=[\d)])\D@($s=" $& $s")=~s!\)(.*?)\(|([^ (])([ */${':'x/\G[+-]/}]*)!$2 !;$+@eg;$_.=$s;y/ //s+s/ $// |
| Inline, inline, inline. | |||
| 119.62 | Alma Media Golf Team | Tue Sep 3 09:46:30 2002 | -p s/\s//g;map{push@o,pop@1while@1*"$_$1[-1]"!~/\(|[\/*][-+]$|\d\D/;/\)/?pop@1:push@1,$_}/(?<![\d)])-?\d+|.?/g;$_="@o
" |
| numbers visit the stack now | |||
| 120.27 | Qingning Huo | Sat Sep 7 08:06:32 2002 | -p y/ ^I//d;s/(?<!\)|\d)-?\d+/ $&/g;1while s/\(\)//||s# (-?\d+)|([^(])(?=[-+)])|([*/])(?=[*/])|(.)$##&&push@0,$+;$_="@0 " |
| 120.80 | Adam Antonik | Fri Sep 6 16:07:18 2002 | -lp use overload'""',sub{${$_[0]}},nomethod,\*a;sub a{$_=pop;bless/g/?\"-$_[0]":\"@_$_"}s/-/- /g+s/\d+/a("$&")/g;*_=eval |
| 121.42 | pom | Thu Sep 5 23:47:10 2002 | -p y/ ^I//d;s/\b/x/g;s/x(.+)x/($1)/;1while s!\(([^()]+)\)!$_=$1;s/x([$1])(-?)x(\PL+)/ $2$3 $1/while/x(\D)/|/x([*\/])/;$_!e |
| 121.59 | Michael Thelen | Thu Sep 5 20:55:00 2002 | -lp y/ ^I//d+s@\(|(?<=[\d)])\D@$z=$:x/\G[+-]/;($s=" $& $s")=~s+\)(.*?)\(|([^( ])([ */$z]*)+$2 +;$+@eg;$_.=$s;y/ //s+s/ $// |
| Accidentally stumbled across the fact that '+' does not need to be popped off the stack when '+' or '-' is seen. I think this is the first time I've ever used $:, ever. | |||
| 121.60 | Mykola Zubach | Wed Sep 4 11:54:31 2002 | -lp y/() \t/<>/d;for(s/(?<!>|\d)-?\d+/<$&>/g;s/<(<[^>]+>)>/$1/||s@>([*/]|(.))<([^<>]+)>(?(2)(?![*/]))@ $3 $1>@;){}y/<>//d |
| 121.60 | Mark Hillebrand | Thu Sep 5 08:47:44 2002 | -lp $_="($_)";y+(-9 ^I+b-s+d;1while s*b([^b]+?)c*$_=$1;for$/qw(di eg){s-(?<=\S)([$/])(g?[^eg$/]+)- $2 $1-g}y+b-s+(-9+;$_*e
|
| one char & tie breaking | |||
| 121.62 | Chia-chi Yeh | Tue Sep 3 17:56:06 2002 | -pl s/\s//g;$_="($_)";0while s!\(([^()]*)\)!$a=$1;for(qw(*/ +-)){0while$a=~s#(\S)([$_])(.*?\S)([*/+-]|$)#$1 $3 $2$4#}$a!e |
| 121.69 | Ton Hospel | Tue Sep 3 18:27:29 2002 | -Xlp sub f{(s/^-?\d+//?$&:a(!s/.//).!s///).pop.(s!^[*/]!!&&$".f(" $&"))}sub a{f.pop.(s/^[+-]//&&$".a($".$&))}s/\s//g;$_=a |
| Back to playing with a real parser | |||
| 122.27 | Qingning Huo | Sat Sep 7 07:04:26 2002 | -p y/ ^I//d;s/(?<!\)|\d)-?\d+/ $&/g;1while s/\(\)//||s#([-+*/])(?=[-+)])|([*/])(?=[*/])| (-?\d+)|(.)$##&&push@o,$+;$_="@o " |
| 122.43 | pom | Tue Sep 3 21:57:18 2002 | -p y/ ^I//d;s/\b/x/g;s/x(.+)x/($1)/;1while s!\(([^()]+)\)!$_=$1;s/x([$1])(-?)x(\PL+)/ $2$3 $1/while/x([*\/])/||/x(\D)/;$_!e |
| 122.64 | Mark Hillebrand | Wed Sep 4 14:56:24 2002 | -lp $_="($_)";y+)(-9 ^I+a-s+d;1while s|b([^ab]+)a|$_=$1;for$/qw(di eg){s:(?<=\S)([$/])(g?[^eg$/]+): $2 $1:g}y+d-s+*-9+;$_|e
|
| Abuse of $/ saves one char. 2nd try | |||
| 122.76 | Adam Antonik | Thu Sep 5 19:17:41 2002 | -lp sub a{$_=pop;bless/g/?\"-$_[0]":\"@_$_"}use overload'""',sub{${$_[0]}},nomethod,\*a;s/-/- /g+s/0*(\d+)/a($1)/g;*_=eval |
| 123.34 | Eugene van der Pijll | Thu Sep 5 16:27:30 2002 | -p s/\s+//g;s/\d+/$&
/g;sub w{s#
([@_*/])(.*)# $2 $1#}sub
f{local
$_=pop;1while s#\(([^()]+)\)#f($1)#e||w||w"-+";$_}
$_=f$_ |
| climbing fast :) | |||
| 123.59 | Michael Thelen | Wed Sep 4 20:46:34 2002 | -lp y/ ^I//d+s@\(|(?<=[\d)])\D@$z="+-"x!/\G[+-]/;($s=" $& $s")=~s/\)(.*?)\(|([^( ])([^($z]*)/$2 /;$+@eg;$_.=$s;y/ //s+s/ $// |
| Tiebreaker improvement. Hopefully the tab char comes through okay. | |||
| 123.60 | Alma Media Golf Team | Mon Sep 2 16:32:21 2002 | -p s/\s//g;map{push@0,pop@1while@1*"$_$1[-1]"!~/\d|\(|[*\/][+-]/;/\)/?pop@1:push@{1-/\d/},$_}/(?<![\d)])-?\d+|.?/g;$_="@0
"
|
| 123.64 | Michael Thelen | Sat Sep 7 17:21:25 2002 | -lp y/ ^I//d+s@\(|(?<=[\d)])\D@$z=!/\G[+-]/&&'"';($"=" $&$\"")=~s+\)(.*?)\(|([^ (])([*/$:$z]*)+$2 +;$+@eg;$_.=$";y/ //s+chop |
| Not my best solution, but using the usage of $: is interesting. | |||
| 123.65 | Michael Thelen | Wed Sep 4 20:18:13 2002 | -lp s/\s//g;s@\(|(?<=[\d)])\D@$z="+-"x!/\G[+-]/;($s=" $& $s")=~s!\)(.*?)\(|([^( ])([^($z]*)!$2 !;$+@eg;$_.=$s;y/ //s;s/ $// |
| Two more strokes with y///s. Now, how to avoid the need for s/ $// ? | |||
| 123.65 | Chia-chi Yeh | Tue Sep 3 17:46:59 2002 | -pl s/\s//g;$_="($_)";0while s!\(([^()]*)\)!$a=$1;for$b('*/','+-'){0while$a=~s#(\S)([$b])(.*?\S)([*/+-]|$)#$1 $3 $2$4#}$a!e |
| 123.76 | Adam Antonik | Wed Sep 4 17:31:34 2002 | -pl sub a{$_=pop;bless[/g/?"-$_[0]":"@_$_"]}use overload nomethod,\*a,'""',sub{$_[0][0]};s/-/- /g+s/0*(\d+)/a($1)/g;$_=eval |
| 124.43 | Eugene van der Pijll | Wed Sep 4 17:40:19 2002 | -lp sub
_{bless\"@_"}use
overload
neg,sub{_"-$_[0]"},qw/nomethod
_
""/,sub{${$_[0]}};s/-/
-/g;s/\d+/_("$&")/g;$_=eval;y/ //s |
| Slightly better tiebreaker. There must be a better way. | |||
| 124.49 | Eugene van der Pijll | Tue Sep 3 20:27:48 2002 | -lp sub
_{bless\"@_"}use
overload
neg,sub{_"-$_[0]"},'""',sub{${$_[0]}},nomethod,'_';s/-/
-/g;s/\d+/_("$&")/g;$_=eval;y/ //s |
| 125.38 | Mtv Europe | Tue Sep 3 17:21:00 2002 | -p y/) ^I/
/d;$a.=/\d/?!push
o,$_:/[^(0]/+/[*\/]/&&do{push o,$/while($/=chop$a)=~//;$/.$_}x/./for/(?<!\d|
)-?\d+|./sg;$_="@o
"
|
| catch pom again! | |||
| 125.50 | pom | Tue Sep 3 09:39:06 2002 | -pl $_="($_)";s/\s//g;s/\b/x/g;1while s!\(([^()]+)\)!$_=$1;s/x([$1])(-?)x(\PL+)/ $2$3 $1/while/x([*\/])/||/x(\D)/;$_!e||s/x// |
| 125.59 | Michael Thelen | Wed Sep 4 19:52:08 2002 | -p s/\s//g;s@\(|(?<=[\d)])\D@$z="+-"x!/\G[+-]/;($s=" $& $s")=~s/\)(.*?)\(|([^( ])([^($z]*)/$2 /;$+@eg;$_.=$s;$_="@{[split]}
" |
| Whoa! One of the thousand combinations I tried actually yielded a better score! | |||
| 126.50 | Stephen Turner | Sun Sep 1 17:43:03 2002 | -pl sub
n{my$p="@_";bless\$p}use
overload
nomethod,sub{n${$_[0]},${$_[1]},pop};y/ ^I//d+s/(?<![\d)])-?\d+/(n"$&")/g;$_=${eval
}
|
| Save two strokes by building a string inside the constructor instead of inside the overloaded operator. | |||
| 126.59 | Michael Thelen | Wed Sep 4 18:46:44 2002 | -p s/\s//g;s@\(|(?<=[\d)])\D@$z=/\G[+-]/||"+-";($s=" $& $s")=~s/\).*?\(|(?<=[^( ])[^($z]*/ /;$&@eg;$_.=$s;$_="@{[/[*-9]+/g]}
" |
| Okay, that \G is freaking me out. I don't know why I even tried it. | |||
| 127.37 | Mtv Europe | Tue Sep 3 16:55:57 2002 | -p y/) ^I/
/d;$a.=/\d/?!push
o,$_:/\(/?0:do{push
o,$/while$/=chop$a,/[*\/]/?$/=~//:$/;$/.$_}x/./for/(?<!\d|
)-?\d+|./sg;$_="@o
"
|
| ahh, today rate is done | |||
| 127.60 | Michael Thelen | Wed Sep 4 18:27:02 2002 | -p s/\s//g;s@\(|(?<=[\d)])\D@$z="+-"x$&!~/[+-]/;($s=" $&$s ")=~s/\).*?\(|(?<=[^( ])[^($z]*/ /;$&@eg;$_.=$s;$_="@{[/[*-9]+/g]}
" |
| Trying to start to use whitespace wisely. Failing quite miserably so far. | |||
| 127.65 | Markus Laire | Sat Sep 7 01:21:17 2002 | -pl s/\s//g;$x=xx;$a=s#[*/]#x$_#?'(([+-] )?x)':x,s/[-+(]$/x$_ x/,$x=~s/$a/$_ $1/for/(?<!\d|\))-?\d+|./g;$_=$x;y/()x / /s;s/ $// |
| 128.38 | Mtv Europe | Mon Sep 2 12:55:50 2002 | -p y/) ^I/
/d;$a.=/\d/?!push
o,$_:/\(/?0:do{push
o,$/while$/=chop$a,/\*|\//?$/=~//:$/;"$/$_"x/./}for/(?<!\d|
)-?\d+|./sg;$_="@o
"
|
| 128.47 | Michael Thelen | Wed Sep 4 17:53:08 2002 | -p s/\s//g;s@\(|(?<=[\d)])\D@$z="+-"x$&!~/[+-]/;($s="$& $s")=~s/\)(.*?)\(|(?<=^[^(])([^($z]*)/ /;$+@eg;s/$/
$s/;$_="@{[split]}
" |
| Negation of =~ instead of the character class saves another stroke. hmm .. you sure do keep a ref buzy :) | |||
| 128.49 | Stephen Turner | Sun Sep 1 13:35:36 2002 | -pl sub
n{my$p=pop;bless\$p}use
overload
nomethod,sub{n"${$_[0]} ${$_[1]} ".pop};y/ ^I//d+s/(?<![\d)])-?\d+/(n"$&")/g;$_=${eval
} |
| Better tie-breaker. | |||
| 128.49 | pom | Mon Sep 2 13:03:03 2002 | -p $_="($_)";y/ ^I//d;s/\b/x/g;1while s!\(([^()]+)\)!$_=$1;s/x(\Q$1\E)(-?)x(\PL+)/ $2$3 $1/while/x([*\/])/||/x([+-])/;$_!e;y/x//d |
| 128.52 | Stephen Turner | Sun Sep 1 13:32:16 2002 | -pl sub
n{my$p=pop;bless\$p}use
overload
nomethod,sub{n"${$_[0]} ${$_[1]} ".pop};y/ ^I//d+s/(?<![\d)])-?\d+/(n"$&")/g;$_=${+eval}
|
| Another stroke bites the dust. | |||
| 128.52 | Alexey Rudenko | Tue Sep 3 11:04:39 2002 | -lp $p=qr'-?\d+|\(([^()]|(??{$p}))*\)';y/ \t//d;1while s/([-+\d)])([-+])($p([*\/]$p)*)/$1 $3 $2/||s/([*\/])($p)/ $2 $1/;y/()//d; |
| 128.59 | Alain "TopMach" Dupuis | Sun Sep 8 00:27:13 2002 | -lp s/\s//g;$-=/\(/,s!\({$-}([^()]+)\){$-}!$_=$1;for$+('*/','+-'){1while s/(\S)([$+])(-?(\d+| .)*)/$1 $3 $2/}$_!ewhile/\S[^\w ]/ |
| Tie breaker optimization | |||
| 128.59 | Mykola Zubach | Tue Sep 3 14:07:03 2002 | -lp y/() \t/<>/d;for(s/(?<![>\d])-?\d+/<$&>/g;s/<(<[^>]+>)>/$1/||s@>([/*]|([+-]))<([^<>]+)>(?(2)([^*/]|$))@ $3 $1>$4@;){}y/<>//d |
| There was invisible "\n" in "links" browser in previously rejected version. Got new one, also improved. | |||
| 128.66 | Alain "TopMach" Dupuis | Sat Sep 7 22:50:47 2002 | -lp s/\s//g;$%=/\(/,s!\({$%}([^()]+)\){$%}!$_=$1;for$o('*/','+-'){1while s#(\S)([$o])(-?(\d+| .)*)#$1 $3 $2#}$_!ewhile/\S[^\w ]/ |
| 129.47 | Michael Thelen | Wed Sep 4 17:50:18 2002 | -p s/\s//g;s@\(|(?<=[\d)])\D@$z="+-"x$&=~/[^+-]/;($s="$& $s")=~s/\)(.*?)\(|(?<=^[^(])([^($z]*)/ /;$+@eg;s/$/
$s/;$_="@{[split]}
" |
| Oops, I had an unnecessary ( in a character class. Now if I could just get rid of $z... | |||
| 129.52 | Stephen Turner | Sun Sep 1 13:24:27 2002 | -pl sub
n{my$p=pop;bless\$p}use
overload
nomethod,sub{n"${$_[0]} ${$_[1]} ".pop};y/ ^I//d+s/(?<![\d)])-?\d+/(n"$&")/g;$_=${eval()}
|
| Cheaper to handle unary minus ourselves. And BoB is beaten 7,5 hours after the rules were available .. impressive | |||
| 129.64 | Markus Laire | Fri Sep 6 22:01:11 2002 | -pl s/\s//g;$x=xx;s/$/ /,/[*\/]/&&$x=~s/[+-] x|x/x$_$&/||s/\(|([+-] )/x$1x/+$x=~s/x/$_/for/(?<!\d|\))-?\d+|./g;$_=$x;s/ \) | x//g |
| 129.76 | Ton Hospel | Mon Sep 2 22:22:29 2002 | -Xlp sub n{/\G-?\d+/cg?$&:!/./g.&a.!//g}sub f{n.pop.(m!\G[*/]!cg&&$".f(" $&"))}sub a{f.pop.(/\G[+-]/cg&&$".a($".$&))}s/\s//g;$_=a |
| Ok, I broke down and wrote an actual parser Let's start with recursive descent | |||
| 129.79 | Eugene van der Pijll | Tue Sep 3 18:17:55 2002 | -lpX sub _{bless\"@_"}use overload neg,sub{_"-@_"},'""',sub{${$_[0]}},nomethod,'_';s/-/ -/g;s/\d+/_("$&")/g;$_=eval;y/ //s;s/ $// |
| This should work... Third time lucky. No "Unknown filetest" errors now. | |||
| 130.47 | Michael Thelen | Wed Sep 4 17:34:56 2002 | -p s/\s//g;s@\(|(?<=[\d)])\D@$z="+-"x$&=~/[(*\/]/;($s="$& $s")=~s/\)(.*?)\(|(?<=^[^(])([^($z]*)/ /;$+@eg;s/$/
$s/;$_="@{[split]}
" |
| More removal of unnecessary complexity. Thank goodness for $+. | |||
| 131.38 | Mtv Europe | Mon Sep 2 12:54:16 2002 | -p y/) ^I/
/d;/\d/?push
o,$_:/\(/?$a.=0:do{push
o,$/while$/=chop$a,/\*|\//?$/=~//:$/;$a.="$/$_"x/./}for/(?<!\d|
)-?\d+|./sg;$_="@o
"
|
| hmm | |||
| 131.66 | Alain "TopMach" Dupuis | Sat Sep 7 22:11:34 2002 | -lp s/\s//g;$%=/\(/,s!\({$%}([^()]+)\){$%}!$_=$1;for$o('*/','+-'){1while s#(\S)([$o])(-?\d+( .|\d+)*)#$1 $3 $2#}$_!ewhile/\S[^\w ]/ |
| 131.82 | TheodoreYoung | Tue Sep 3 19:45:10 2002 | -lp sub _{bless\"@_"}use overload'""',sub{${$_[0]}},neg,sub{_"-$_[0]"},nomethod,sub{_"@_[0,1,3]"};s/-/ -/g;s/\d+/ _('$&')/g;$_=eval |
| Didn't quite retire the idea, eh? :-) | |||
| 132.35 | Mtv Europe | Mon Sep 2 12:33:44 2002 | -p y/) ^I/
/d;/\d/?push
o,$_:/\(/?$a.=0:do{push
o,$/while$/=chop$a,/\*|\//?$/=~//:$/;/
/
or$a.=$/.$_}for/(?<!\d|
)-?\d+|./sg;$_="@o
"
|
| outrun pom at tie again! | |||
| 132.37 | pom | Mon Sep 2 11:11:43 2002 | -p $_="($_)";y/ ^I//d;s/\b/x/g;1while s!\(([^()]+)\)!$_=$1;$*=$1,s/y(-?)x(\PL+)/ $1$2 $*/while s-x([*/])-y-||s/x([+-])/y/;$_!e;y/x//d |
| Sorry, I sent a wrong version, this one works! | |||
| 132.59 | Alma Media Golf Team | Mon Sep 2 15:00:20 2002 | -p s/\s//g;map{push@0,pop@1while@1*')-++-*//*'=~/\Q$_\E.*\Q$1[-1]/;/\)/?pop@1:push@{1-/\d/},$_}"($_)"=~/(?<![\d)])-?\d+|./g;$_="@0
" |
| 132.65 | Chia-chi Yeh | Tue Sep 3 05:09:22 2002 | -pl s/\s//g;$_="($_)";@p=qw(*/ +-);0while s&\(([^(]*?)\)&$a=$1;0while$a=~s#(\S)([$p[$i]])(.*?\S)([*/+-]|$)#$1 $3 $2$4#||($i^=1);$a&e |
| 132.72 | Mark Hillebrand | Wed Sep 4 11:10:41 2002 | -lp $_="($_)";y:)(-9 ^I:a-s:d;s.([b-g])g.$1-.g;1while s!b([^ab]+)a!$_=$1;for$k('di','eg'){s:([$k])([^eg$k]+): $2 $1:g}y:d-s:*-9:;$_!e
|
| 1st try | |||
| 132.80 | Jasvir Nagra | Sun Sep 8 04:56:58 2002 | -pl use overload nomethod,sub{($a,$b,$c,$_)=@_;/"/?"@{$a}":bless[ref$b?@_[$c,!$c,3]:-"@_"]};s/-/- /g;s/0*(\d+)/bless([$1])/g;$_=eval
|
| 133.23 | Markus Laire | Fri Sep 6 19:43:56 2002 | -p s/\s//g;$x=" ";s/$/ /,/[*\/]/&&$x=~s/[+-] | / $_$&/||s/\(|([+-] )/ $1 /+$x=~s/ /$_/for/(?<!\d|\))-?\d+|./g;$_=$x;s/ \) //g;s/ $// |
| It seems it fails this test: Input: 1 + 2 * 3 Output: 1 2 + 3 * | |||
| 133.36 | pom | Mon Sep 2 11:00:54 2002 | -p $_="($_)";y/ ^I//d;s/\b/x/g;1while s!\(([^()]+)\)!$_=$1;s/y(.)(-?)x(\PL+)/ $2$3 $1/while s-x([*/])-y$1-||s/x([+-])/y$1/;$_!e;y/x//d |
| 133.41 | Mtv Europe | Mon Sep 2 10:35:29 2002 | -p y/ ^I//d;/\(/?$#a++:/\d/?push
o,$_:do{push
o,$,while$,=pop
a,/[*\/]/?$,=~//:$,;/\)/||push
a,$,,$_}for/(?<!\d|\))-?\d+|.?/g;$_="@o
"
|
| damn, this looks like the limit for this algorithm, and i wonder what pom will answer? | |||
| 133.47 | Michael Thelen | Wed Sep 4 17:30:30 2002 | -p s/\s//g;s@\(|(?<=[\d)])\D@$z="+-"x$&=~/[(*\/]/;($s="$& $s")=~s/\)(.*?)\(|^([^(])([^($z]*)/$2 /;$1||$3@eg;s/$/
$s/;$_="@{[split]}
" |
| 10-stroke gain, yay! It's nice to get rid of an entire statement. | |||
| 133.53 | pom | Mon Sep 2 08:41:27 2002 | -p $_="($_)";y/ ^I//d;s/\b/x/g;1while s!\(([^()]+)\)!$_=$1;$_="$` $2$3 $1$'"while/x([*\/])(-?)x(\PL+)/||/x(\D)(-?)x(\PL+)/;$_!e;y/x//d |
| 133.62 | Keith Calvert Ivey | Sun Sep 8 03:03:59 2002 | -p s/\s//g;map{$0=m+[*/]+?'*/':'^(';$0[@0]=pop@1until/\(|\d/|"@1"!~/[$0]$/;/\)/?pop@1:push@{1-/\w/},$_}/(?<![\d)])-?\d+|.?/g;$_="@0
" |
| I hope I retyped this correctly from my laptop, which currently has no Internet connection, into my parents' computer, which has no Perl. Who needs to visit family when I can beat Andrew? You, sir, are a true golfer. | |||
| 133.63 | Chia-chi Yeh | Tue Sep 3 04:34:34 2002 | -pl s/\s//g;$_="($_)";@p=qw(*/ +-);0while s/\(([^(]*?)\)/$a=$1;0while$a=~s#(\S)([$p[$i]])(.*?\S)([*\/+-]|$)#$1 $3 $2$4#||($i^=1);$a/e |
| 133.69 | Andrew Savige | Sat Sep 7 17:33:47 2002 | -lp y+ ^I++d;$*.=/\d/?"$_ ":($s=~s~^.*?(?=@{['|'x/\(/.'-|\+|'x/[*\/]/]}\(|$)~$_ ~,$&),$s=~s+\) . ++for/(?<![\d)])-?\d+|.?/g;$_=$*;chop
|
| 133.79 | Adam Antonik | Tue Sep 3 17:28:17 2002 | -l use overload nomethod,sub{$_=pop;bless[/g/?"-$_[0]":"@_$_"]},'""',sub{$_[0][0]};$_=<>;s/-/- /g;s/0*(\d+)/\(bless[$1])/g;print eval |
| 134.69 | Andrew Savige | Sat Sep 7 08:06:47 2002 | -lp y+ ^I++d;$*.=/\d/?"$_ ":($s=~s~^.*?(?=@{['^|'x/\(/.'-|\+|'x/[*\/]/]}\(|$)~$_ ~,$&),$s=~s+\) . ++for/(?<![\d)])-?\d+|.?/g;$_=$*;chop
|
| I feel a bit embarassed flogging the same horse, but I am too tired to think of anything new. Gee, I thought Keith had given up, but he is right behind me now and I fear he will finish stronger. | |||
| 134.78 | Jasvir Nagra | Sun Sep 8 04:52:11 2002 | -pl use overload nomethod,sub{$_[3]=~/"/?"@{$_[0]}":bless[ref$_[1]?@_[$_[2],!$_[2],3]:-"@_"]};s/-/- /g;s/0*(\d+)/bless([$1])/g;$_=eval
|
| 136.33 | Eugene van der Pijll | Thu Sep 5 16:12:54 2002 | -p s/\s+//g;s/\d+/a$&
/g;sub w{s#
([@_*/])(-?)a(.*)# $2$3 $1#}sub
f{local
$_=pop;1while
s#\(([^()]+)\)#f($1)#e||w||w"-+";$_}$_=f$_;s/a// |
| 136.48 | Mtv Europe | Mon Sep 2 07:26:50 2002 | -p s/\s//g;/\(/?$#:++:/\d/?push
o,$_:do{push
o,pop@:while/[*\/]$/?"@:"=~//:$:[-1];/\)/?$#:--:push@:,$_}for/(?<!\d|\))-?\d+|.?/g;$_="@o
"
|
| looks like my previous attempt failed because i misunderstood 'negative' numbers. | |||
| 136.70 | Andrew Savige | Sat Sep 7 03:05:48 2002 | -lp y+ ^I++d;$*.=/\d/?"$_ ":($s=~s~^.*?(?=@{["[@{['-+'x/[*\/]/]}(]|\$"x!/\(/]})~$_ ~,$&),$s=~s+\) . ++for/(?<![\d)])-?\d+|.?/g;$_=$*;chop
|
| I hope `/ refs this one for I have smashed the refs 138 wall with my trusty one iron (much to my surprise I must admit). | |||
| 136.81 | Jasvir Nagra | Sun Sep 8 04:25:36 2002 | -pl use overload'""',sub{"@{$_[0]}"},nomethod,sub{bless[defined$_[1]?@_[$_[2],!$_[2],3]:-"@_"]};s/-/- /g;s/0*(\d+)/bless([$1])/g;$_=eval
|
| 137.31 | Qingning Huo | Sat Sep 7 06:57:12 2002 | -p y/ ^I//d;s/(?<!\)|\d)-?\d+/ $&/g;s/\(\)//||s#([-+*/])(?=\))|([*/])(?=[-+*/])|([-+])(?=[-+])| (-?\d+)|(.)$##&&push@o,$+while/./;$_="@o " |
| 137.36 | pom | Sun Sep 1 17:59:51 2002 | -p $_="($_)";y/ ^I//d;s/\b/x/g;1while s!\(([^()]+)\)!$_=$1;1while s-x([*/])(.?)x(\PL+)- $2$3 $1-||s/x(\D)(-?)x(\PL+)/ $2$3 $1/;$_!e;y/x//d |
| The tiebreaker for this hole is quite fun... makes the pm easier to read :) | |||
| 138.48 | BoB (Best of Breed - referees) | Sun Sep 1 05:21:32 2002 | -pl sub
e{map$_&&=/(.*\w)(\/|\*)/|/(.*\w)(\+|-)/&&e($1,$',$2)||e($o{$_})||$_,@_=@_;"@_"}s/\s//g;$o{$~++}=$1while
s/\(([^()]+)\)/$~/;$_=e$_
|
| Okay, let's see whether submitting works. | |||
| 138.55 | Mykola Zubach | Tue Sep 3 10:54:38 2002 | -lp y/() \t/<>/d;s/(?<![>\d])(-?\d+)/<$1>/g;for($a="<([^<>]+)>";s/<$a>/<$1>/||s@$a([
/*]|([+-]))$a(?(3)([^*/]|$))@<$1 $4 $2>$5@;){}y/<>//d |
| It's my first try to play perlgolf
Looking good! | |||
| 138.63 | Keith Calvert Ivey | Sat Sep 7 11:31:37 2002 | -p s/\s//g;map{if(!/\(|\d/){$0=m+[*/]+?'*/':'^(';$0[@0]=pop@1while"@1"=~/[$0]$/}/\)/?pop@1:push@{1-/\w/},$_}/(?<![\d)])-?\d+|.?/g;$_="@0
" |
| That push() didn't last long. It's only 0.01 improvement, but I'm running out of time. Hurry up, Andrew is not far ahead! :-) | |||
| 138.64 | Keith Calvert Ivey | Sat Sep 7 11:20:06 2002 | -p s/\s//g;map{if(!/\(|\d/){$0=m+[*/]+?'*/':'^(';push@0,pop@1while"@1"=~/[$0]$/}/\)/?pop@1:push@{1-/\w/},$_}/(?<![\d)])-?\d+|.?/g;$_="@0
" |
| Changing back to push() made it a lot faster | |||
| 138.75 | Andrew Savige | Fri Sep 6 21:48:38 2002 | -lp y~ ^I~~d;$x.=/\d/?"$_ ":($s=~s~@{[/\(/?v94:".*?(?=[@{['-+'x/[*\/]/]}(]|\$)"]}~$_ ~,$&),$s=~s~\) . ~~for/(?<![\d)])-?\d+|.?/g;$_=$x;chop
|
| Caught the refs!!! Amazingly just by flogging the same ol' dead horse. Gee, Amir is moving up fast from behind. Recite litany against fear. | |||
| 139.81 | Jasvir Nagra | Sun Sep 8 03:59:35 2002 | -pl use overload'""',sub{$_[0][0]},neg,sub{bless[-"@_"]},nomethod,sub{bless["@_[$_[2],!$_[2],3]"]};s/-/- /g;s/0*(\d+)/bless([$1])/g;$_=eval
|
| 140.23 | Markus Laire | Fri Sep 6 14:26:55 2002 | -p s/\s//g;s/(?<!\d|\))-/f/g;$x=" ";s/$/ /,/[*\/]/&&$x=~s/[-+]? / $_$&/||s/\(|([+-] )/ $1 /+$x=~s/ /$_/for/\w+|./g;$_=$x;y/f) /- /s;s/ $// |
| 140.46 | Amir Karger | Fri Sep 6 20:27:18 2002 | -pl y/ ^I//d;s/(?<![\d)])-/^I/g;$*=qr/\(([^()]+|(??{$*}))*\)|^I?\d+/;@*=qw(+- */);s+([$*[$-%2]])($*( $* [*/])*)+ $2 $1+gwhile$-++-1e4;y/^I()/-/d
|
| No mas! | |||
| 140.47 | Stephen Turner | Sun Sep 1 12:10:38 2002 | -pl sub
n{my$p=pop;bless\$p}use
overload
nomethod,sub{n$_[3]lt
9?"${$_[0]} ${$_[1]} ".pop:"-${$_[0]}"};s/-/
-/g+s/\d+/(n"$&")/g;$_=${eval()} |
| Minor improvements | |||
| 140.53 | Amir Karger | Fri Sep 6 20:09:49 2002 | -pl s/\s//g;s/(?<![\d)])-/x/g;$*=qr/\(([^()]+|(??{$*}))*\)|x?\d+/;@*=qw(+- */);s#([$*[$-%2]])($*( $* [*/])*)# $2 $1#gwhile$-++<1e4;y/x()/-/d
|
| Gotcha, Andrew! (Maybe.) | |||
| 140.63 | Keith Calvert Ivey | Sat Sep 7 04:24:56 2002 | -p s/\s//g;map{if(!/[(\d]$/){$0=m+[*/]+?'*/':'^(';@0=(@0,pop@1)while"@1"=~/[$0]$/}/\)/?pop@1:push@{1-/\w/},$_}/(?<![\d)])-?\d+|.?/g;$_="@0
" |
| 140.66 | Alain "TopMach" Dupuis | Sat Sep 7 21:59:52 2002 | -lp s/\s//g;$%=/\(/,s!\({$%}([^()]+)\){$%}!$_=$1;for$o('*/','+-'){1while s#(\S)([$o])(-?\d+( .|\d+)*)#$1 $3 $2#}$_!ewhile/(\d|[^\w ])[^\w ]/ |
| 140.75 | Andrew Savige | Fri Sep 6 13:02:27 2002 | -lp y~ ^I~~d;$x.=/\d/?"$_ ":($s=~s~@{[/\(/?v94:".*?(?=[@{['-+'x/[*\/]/]}(]|\$)"]}~$_ ~,$&),$s=~s~\) . ~~for/(?<![\d)])-?\d+|./g;$_=$x.$s;chop
|
| That horse just keeps on going. | |||
| 141.50 | Stephen Turner | Sun Sep 1 11:32:40 2002 | -pl sub
n{my$p=pop;bless\$p}use
overload
nomethod,sub{n$_[3]lt 9?"${$_[0]} ${$_[1]} $_[3]":"-${$_[0]}"};s/-/
-/g;s/\d+/(n"$&")/g;$_=${eval()}
|
| Let Perl sort it out. That's very cool! | |||
| 141.65 | Chia-chi Yeh | Tue Sep 3 04:05:20 2002 | -p s/\s//g;$_="($_)";@p=qw(*/ +-);$i=0while s/\(([^(]*?)\)/$a=$1;0while$a=~s#(\S)([$p[$i]])(.*?\S)([*\/+-]|$)#$1 $3 $2$4#||++$i%2;$a/e;$_.=$/ |
| 142.56 | Rick Klement | Sun Sep 1 21:28:46 2002 | -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/=/-/ |
| 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. | |||
| 142.56 | Amir Karger | Fri Sep 6 16:18:29 2002 | -pl s/\s//g;$z=qr/\(([^()]+|(??{$z}))*\)|-?\d+/;s#(?<=\S)([*/])($z)# $2 $1#g,s#((?<=[\d)*/])[+-])($z( $z [*/])*)# $2 $1#gwhile$q++<1e4;y/()//d
|
| Aha! One more rung! This may be my last gasp, though. | |||
| 142.58 | John Williams | Fri Sep 6 06:49:03 2002 | -pl $_="(@{[/\d+|\S/g]} )";s/([^\d)] -) /$1/g;1while s#\([^()]+\)#$_=$&,s= ([*/]) (\S+)=,$2,$1=||s/ ([+-]) (\S+)/,$2,$1/||y/() //d,$_#e;y/,/ /
|
| 142.80 | TheodoreYoung | Tue Sep 3 19:05:16 2002 | -l sub n{bless\"@_"}use overload'""',sub{${$_[0]}},neg,sub{n"-$_[0]"},nomethod,sub{n"@_[0,1,3]"};$_=<>;s/(-?)[0 ]*(\d+)/ $1 n($2)/g;print eval |
| Sorry for so many posts in one day. I think it is time to retire this idea. | |||
| 142.82 | Jasvir Nagra | Sun Sep 8 03:48:07 2002 | -pl use overload'""',sub{$_[0][0]},neg,sub{bless[-"@_"]},nomethod,sub{bless["@_[$_[2],!$_[2]] ".pop]};s/-/- /g;s/0*(\d+)/bless([$1])/g;$_=eval
|
| Oh my. I really really had given up - just happened to read perldoc overload one last time! | |||
| 143.39 | pom | Sun Sep 1 14:35:06 2002 | -p $_="($_)";y/ ^I//d;s/(?<!\d|\))-?\d+/x$&x/g;1while s!\(([^()]+)\)!$_=$1;1while s-x([*/])x(\PL+)- $2 $1-||s/x([+-])x(\PL+)/ $2 $1/;$_!e;y/x//d |
| Thanks to mtve for the \PL trick! | |||
| 143.52 | Michael Thelen | Wed Sep 4 17:16:56 2002 | -p s/\s//g;s@\(|(?<=[\d)])\D@$y=$&eq')'&&'\(';$z="+-"x$&=~/[(*\/]/;($s="$& $s")=~s/^(\)|([^(]))([^($z]*)$y/$2 /;$3@eg;s/$/
$s/;$_="@{[split]}
" |
| First stab at consolidating the various cases into a single substitution. | |||
| 143.55 | Andrew Savige | Fri Sep 6 12:13:13 2002 | -lp y~ ^I~~d;$x.=/\d/?"$_ ":
($s=~s~@{[/\(/?v94:".*?(?=[@{['-+'x/[*\/]/]}(]|\$)"]}~$_ ~,$&),
$s=~s~\) . ~~,for/(?<![\d)])-?\d+|./g;$_=$x.$s;chop
|
| Much cleaner now. | |||
| 143.72 | Kuang-che Wu | Mon Sep 2 08:56:10 2002 | -lp sub e{my($i)=@_;$i--?do{e($i);eval"e $i;push\@1,'$&'"while$i?/\G[+-]/cg:/\G[*\/]/cg}:/\G-?\d+/cg?push@1,$&:/./g+e(2)+//}s/\s//g+e 2;$_="@1" |
| 144.51 | Michael Thelen | Wed Sep 4 06:08:07 2002 | -p s/\s//g;s@([()])|(?<=[\d)])\D@$s="$& $s";$1?$s=~s/\)(.*?)\(//&&$1:($z="+-"x$&!~/[+-]/,$s=~s/(?<=.)[^($z]*/ /,$&)@eg;s/$/
$s/;$_="@{[split]}
" |
| Replaced [-+*/] with \D, that's pretty much it for now. | |||
| 144.57 | Amir Karger | Fri Sep 6 16:08:05 2002 | -pl s/\s//g;$z=qr/\(([^()]+|(??{$z}))*\)|-?\d+/;s#(?<=\S)([*/])($z)# $2 $1#g,s#((?<=[\d)*/])[+-])($z( $z [*/])*)# $2 $1#gwhile$q++<1e4;s/[()]//g
|
| Kill some apparently unneeded groups. | |||
| 144.65 | Michiel van Leeuwen | Sat Sep 7 22:44:13 2002 | -p s/\s//g;s%(?<!\d|\))-?\d+|.%$_="$& ";s|\D |$b='*/'x/[^( ]/."+-"x/[)+-]/."]*)".'\( 'x/\)/;$s=~s~([ $b~"$_"x/[^) ]/~e;$1|e;$_%eg;$_.=$s;s/ $/ / |
| 144.67 | Alain "TopMach" Dupuis | Sat Sep 7 21:11:54 2002 | -lp s/\s//g;$%=/\(/,s!\({$%}([^()]+)\){$%}!$_=$1;for$o('*/','+-'){1while s#([^SO])([$o])(-?\d+(O.|S\d+)*)#$1S$3O$2#}$_!ewhile/(\d|\W)\W/;y/SO/ / |
| 145.57 | John Williams | Thu Sep 5 01:12:44 2002 | -pl $_="(@{[/\d+|\S/g]} )";s/(?<![\d)] )- /-/g;1while s#(\([^()]+\))#$_=$1,s= ([*/]) (\S+)=,$2,$1=||s/ ([+-]) (\S+)/,$2,$1/||y/() //d,$_#e;y/,/ /
|
| s/(.).../$1.../ was rather silly | |||
| 147.21 | Markus Laire | Fri Sep 6 13:49:33 2002 | -p s/\s//g;s/(?<!\d|\))-/f/g;$x=$/x2;s/$/ /,/[*\/]/&&$x=~s/[-+]? / $_$&/ or s/[+-] / $_ /,s/\(/ /,$x=~s/ /$_/for/\w+|./g;$_=$x;y/f) /- /s;s/ $// |
| Finally getting forward | |||
| 147.57 | Andrew Savige | Fri Sep 6 08:02:17 2002 | -lp y~ ^I~~d;$x.=/\d/?"$_ ":!/\(/&&
($s=~s~.*?(?=[@{['-+'x/[*\/]/]}(]|$)~~,$&),
$s="$_ $s",$s=~s~-?\d+ |\)...~~for/(?<![\d)])-?\d+|./g;$_=$x.$s;chop
|
| Getting slower and grottier. Time for a new approach. | |||
| 147.61 | Mtv Europe | Sun Sep 1 14:02:13 2002 | -pi<([^>]+)> y/ ^I//d;s/(?<!\d|\))-?\d+/<$&>/g;s/.*/($&)/;1while
s#\(([^()]+)\)#$_=$1;for$i('*/','+-'){s/$^I([$i])$^I/<$1 $3 $2>/&&redo}$_#e;y/<>//d
|
| 147.65 | Keith Calvert Ivey | Sat Sep 7 04:15:21 2002 | -p s/\s//g;map{if(/[^(\d]$/){$0=/[)+-]/?'^(':'*/';@0=(@0,pop@1)while"@1"=~/[$0]$/}/\)/?pop@1:push@{1-/\w/},$_}"($_)"=~/(?<![\d)])-?\d+|./g;$_="@0
" |
| 147.75 | Kuang-che Wu | Sun Sep 1 21:26:11 2002 | -lp @x=qw(*/ +-);sub e{my($i)=@_;$i--?do{e($i);eval"e $i;push\@a,'$&'"while/\G[$x[$i]]/cg}:/\G-?\d+/cg?push@a,$&:/\G./g+e(2)+//}s/\s//g;e 2;$_="@a" |
| 148.48 | Michael Thelen | Wed Sep 4 04:24:48 2002 | -p s/\s//g;s@([()])|(?<=[\d)])([-+])|[*/]@$s="$& $s";$1?$s=~s/\)(.*?)\(//&&$1:($z=!$2&&"+-",$s=~s/(.)([^($z]*)/$1 /,$2)@eg;s/$/
$s/;$_="@{[split]}
" |
| From where I started, I never thought I would get this far, but it's amazing what a whole lot of staring can accomplish. Looking good | |||
| 148.57 | Amir Karger | Fri Sep 6 16:00:18 2002 | -pl s/\s//g;$z=qr/\(((?>[^()]+)|(??{$z}))*\)|-?\d+/;s#(?<=\S)([*/])($z)# $2 $1#g,s#((?<=[\d)*/])[+-])($z( $z [*/])*)# $2 $1#gwhile$q++<1e4;s/[()]//g
|
| That's more like it! Now as long as noone else moves up at all, I can call it a respectable finish. Hm. Maybe I could hack sf.net... | |||
| 149.25 | Jukka Suomela | Mon Sep 2 15:05:48 2002 | -p s//ac/;s/\s//g;1while s,(a.*)(c(-?\d+)|([*/]) (?=[*-/])|([-+]) (?=[-+])),$3$4$5 $1 ,||s, ([^)]),$1c,||s,c.,dc,||s,d ., ,||s,(a.*)(.),$2 $1,;s/ a// |
| 149.50 | Andrew Savige | Fri Sep 6 07:16:22 2002 | -lp y~ ^I~~d;$x.=/\d/?"$_ ":
!/\(/&&($s=~s~.*?(?=[@{['-+'x/[*\/]/]}(]|$)~~,$&),
/\d/||($s="$_ $s",$s=~s~\)...~~)
for/(?<![\d)])-?\d+|./g;$_=$x.$s;chop
|
| grotty 'next' ... gone! grotty 'substr' ... gone! ... solution still grotty :-( Oh well, at least I broke 150, which I never expected to. Mad Dutch described his stupendous 98 as "quick and dirty". I wonder, is it just plain filthy or is it *really* pornographic? I suppose Rick could take his revenge and label the person who created it as "clearly insane". :) | |||
| 149.64 | Chia-chi Yeh | Tue Sep 3 03:33:15 2002 | -p s/\s//g;$_="($_)";@p=qw(*/ +-);$i=0while s/\(([^\(\)]*)\)/$a=$1;0while$a=~s#(\S)([$p[$i]])(.*?\S)([*\/+-]|$)#$1 $3 $2$4#||(++$i&&$i<2);$a/e;$_.=$/ |
| Learning Perl is a nice book. ^^" | |||
| 150.35 | Eugene van der Pijll | Thu Sep 5 16:06:27 2002 | -p s/\s+//g;s/((?<!\)|\d)-)?\d+/a$&
/g;sub w{s#
([@_])a(.*)# $2 $1#}sub
f{local
$_=pop;1while
s#\(([^()]+)\)#a.f($1)#e||w"*/"or w"-+";s/a//;$_}$_=f$_ |
| 151.67 | Alain "TopMach" Dupuis | Fri Sep 6 18:26:03 2002 | -lp s/\s//g;$%=/\(/,s!\(?([^()]+)\){$%}!$_=$1;for$o('*/','+-'){1while s#(-?\d+)([$o])(-?\w+)#"$1S$3So".ord$2#e}$_!ewhile/\d\W/;y/S/ /;s/o(\d+)/chr$1/eg |
| 151.69 | Michiel van Leeuwen | Fri Sep 6 22:22:41 2002 | -p s/\s//g;s%(?<!\d|\))-?\d+|.%$_="$& ";s/\) /$s=~s~(.*?)\( ~~;$1/e||s|\D |$b=" */"x/[^( ]/;$a="+-"x/[+-]/;$s=~s~[ $b$a]*~$_~;$&|e;$_%eg;$_.=$s;s/ $/ / |
| 153.35 | Rick Klement | Sun Sep 1 17:31:10 2002 | -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/=/-/ |
| to handle (-1+2) thanks for the new test | |||
| 153.48 | Chris Dolan | Fri Sep 6 18:13:16 2002 | -p sub
f{s/^-?\d+//?push@t,$&:s/.//+e("+-")+s///}sub
e{eval$x;while(s/^[@_]//){my$p=$&;eval$x;push@t,$p}}$x='$_[0]=~/-/?e("*/"):f';s/\s//g;e"+-";s/^/@t
/ |
| Oops, last submission had a copy-n-paste error | |||
| 153.58 | Andrew Savige | Fri Sep 6 00:30:42 2002 | -lp y~ ^I~~d;/\d/&&($x.="$_ ",next),
/\(/||($s=~s~.*?(?=[@{['-+'x/[*\/]/]}(]|$)~~,$x.=$&),
$s=/\)/?substr$s,2:"$_ $s"for/(?<![\d)])-?\d+|./g;$_=$x.$s;chop
|
| Hurrah, exactly 100 strokes whittled from my first entry. Never whittled that much before. And puts me a nostril ahead of Chris Dolan. ^.^ | |||
| 153.69 | Michael Thelen | Wed Sep 4 03:32:05 2002 | -lp s/\s//g;s@([()])|(?<=[\d)])([-+])|[*/]@$".($1?($s=$1.$s)=~s/\)(.*?)\(//&&$1:($x=$&,$z=!$2&&"+-",$s=~s/^[^($z]*/$x /,$&))@eg;$_=join$","$_ $s"=~/\S+/g |
| Starting to cut down on the parentheses, finally! | |||
| 154.43 | Chris Dolan | Fri Sep 6 18:11:48 2002 | -p sub
f{s/^-?\d+//?push@t,$&:s/.//+e("+-")+s///}sub
e{eval$x;while(s/^[@_]//){my$p=$&;eval$x;push@t,$p}}$x='$_[0]=~/-/?e("*/"):f';s/
\s//g;e"+-";s/^/@t
/ |
| What a horrible hack for just one stroke... Sigh... | |||
| 154.47 | Chris Dolan | Fri Sep 6 17:52:33 2002 | -p sub
f{s/^-?\d+//?push@t,$&:s/.//+&e+s///}sub
t{f;while(s+^[*/]++){my$m=$&;f;push@t,$m}}sub
e{t;while(s/^[+-]//){my$p=$&;t;push@t,$p}}s/\s//g;e;s/^/@t
/ |
| just a tiebreaker improvement over my previous solution | |||
| 154.67 | Keith Calvert Ivey | Sat Sep 7 04:08:54 2002 | -p s/\s//g;for("($_)"=~/(?<![\d)])-?\d+|./g){if(/[^(\d]$/){$0=/[)+-]/?'^(':'*/';@0=(@0,pop@1)while"@1"=~/[$0]$/}/\)/?pop@1:push@{/\w/?\@0:\@1},$_}$_="@0
" |
| 154.71 | Michiel van Leeuwen | Wed Sep 4 21:32:54 2002 | -p s/\s//g;s%(?<!\d|\))-?\d+|.%$_="$& ";s/\( /$s=$_.$s;""/e;s/\) /$s=~s~(.*?)\( ~~;$1/e||s|\D |$a="+-"x/[+-]/;$s=~s~[ */$a]*~$_~;$&|e;$_%eg;$_.=$s;s/ $/ / |
| Negative lookback is a positive thing here | |||
| 154.77 | Chris Dolan | Mon Sep 2 03:59:07 2002 | -lp sub f{s/^-?\d+//?push@t,$&:s/.//+&e+s///}sub t{f;while(s+^[*/]++){my$m=$&;f;push@t,$m}}sub e{t;while(s/^[+-]//){my$p=$&;t;push@t,$p}}s/\s//g;e;$_="@t" |
| three part recursion for expression, term and factor components | |||
| 155.28 | Amir Karger | Fri Sep 6 15:52:35 2002 | -pl s/\s//g;
$z=qr/\((?:(?>[^()]+)|(??{$z}))*\)|-?\d+/;
s#(?<=\S)([*/])($z)# $2 $1#g,
s#((?<=[\d)*/])[+-])($z( $z [*/])*)# $2 $1#gwhile$q++<1e4;
s/[()]//g;
|
| 155.51 | Andrew Savige | Thu Sep 5 08:41:52 2002 | -lp y~ ^I~~d;/\d/&&($x.="$_ ",next),
/\(/||($s=~s~.*?(?=[@{['-+'x/[*\/]/]}(]|$)~~,$x.=$&),
$s=/\)/?substr$s,2:"$_ $s"for/(?<![\d)])-?\d+|\S/g;
$_=$x.$s;chop
|
| By pure luck, I happened to be reading one of my favourite books,
the shiny ball book by Joseph N Hall. He suggests on page 62,
"Let's ignore white-space ... it could have been tr-ed out beforehand".
Of course, "tr-ed" in golfspeak is "y-ed". ;)
This simple idea just saved me 20 strokes. Amazing!
Took you long enough ;) | |||
| 156.68 | Keith Calvert Ivey | Sat Sep 7 03:52:35 2002 | -p s/\s//g;$_="($_)";for(/(?<![\d)])-?\d+|./g){if(/[^(\d]$/){$0=/[)+-]/?'^(':'*/';@0=(@0,pop@1)while"@1"=~/[$0]$/}/\)/?pop@1:push@{/\w/?\@0:\@1},$_}$_="@0
" |
| 156.79 | Jasvir Nagra | Sun Sep 8 02:01:44 2002 | -lp use overload'""',sub{$_[0][0]},neg,sub{bless[-"@_"]},map{my$z=$_;$_,sub{bless["@_[$_[2],!pop] $z"]}}qw!+ - * /!;s/-/- /g;s/0*(\d+)/bless([$1])/g;$_=eval
|
| 157.26 | Jukka Suomela | Sun Sep 1 23:19:50 2002 | -p s//ac/;s/\s//g;1while s,(a.*)c(-?\d+),$2 $1 ,||s,(a.*)([*/](?= [*-/])|[-+](?= [-+])),$2 $1,||s, ([*-/]),$1c,||s,c.,dc,||s,d ., ,||s,(a.*)(.),$2 $1,;s/ a// |
| 157.68 | Alain "TopMach" Dupuis | Fri Sep 6 16:58:04 2002 | -lp s/\s//g;$q=/\(/?'':'?',s!\($q([^()]+)\)$q!$_=$1;for$o('*/','+-'){1while s#(-?\d+)([$o])(-?\w+)#"$1S$3So".ord$2#e}$_!ewhile/\d\W/;y/S/ /;s/o(\d+)/chr$1/eg |
| 158.35 | Eugene van der Pijll | Thu Sep 5 16:02:07 2002 | -p s/\s+//g;s/((?<!\)|\d)-)?\d+/a$&
/g;sub w{1while s#
([@_])a(.*)# $2 $1#}sub
f{local
$_=pop;1while
s#\(([^()]+)\)#a.f($1)#e;w('*/');w('-+');y/a//d;$_}$_=f$_ |
| 159.55 | John Williams | Wed Sep 4 23:52:36 2002 | -pl $_="(@{[/\d+|\S/g]} )";s/(?<![\d)] )- /-/g;1while s#(\([^()]+\))#$_=$1,s=(\S+) ([*/]) (\S+)=$1,$3,$2=||s/(\S+) ([+-]) (\S+)/$1,$3,$2/||y/() //d,$_#e;y/,/ / |
| remove sub,local,extra\s | |||
| 160.68 | Michael Thelen | Wed Sep 4 02:56:00 2002 | -lp s/\s//g;s@(\()|(\))|(?<=[\d)])([-+])|[*/]@$".($1?$s!~s/^/(/:$2?$s=~s/(.*?)\(//&&$1:($x=$&,$z=!$3&&"+-",$s=~s/^[^($z]*/$x /,$&))@eg;$_=join$","$_ $s"=~/\S+/g |
| Hooray! 12th place at long last! It's mine, all mine! | |||
| 161.26 | Markus Laire | Fri Sep 6 13:17:17 2002 | -p s/\s//g;s/(?<!\d|\))-/f/g;$x=$/x2;s/$/ /,/[*\/]/&&$x=~s/[-+]? / $_$&/m&&next,s/[+-] / $_ /,s/\( / /,s/\)/_/,$x=~s/ /$_/mfor/\w+|./g;$_=$x;y/f_ /- /s;s/ $// |
| 161.43 | Markus Laire | Sun Sep 1 10:57:42 2002 | -pl %w='*b/c+d-e'=~/./g;s/\s//g;s/(?<!\d|\))-/f/g;$_="($_)";1
while
s#\(([^()]+)\)#$a=$1;for$b('*/','+-'){1
while$a=~s/([$b])(\w+)/a$2a$w{$1}/}$a#e;y#a-f# */+-#s |
| Final optimizations, better logic needed. | |||
| 161.70 | Michiel van Leeuwen | Wed Sep 4 20:13:07 2002 | -pl s/\s//g;s%((?<=[(*+/-])-|^-)?\d+|.%$_="$& ";s/\( /$s=$_.$s;""/e;s/\) /$s=~s~(.*?)\( ~~;$1/e||s|\D |$a="+-"x/[+-]/;$s=~s~[ */$a]*~$_~;$&|e;$_%eg;$_.=$s;s/ $// |
| 162.70 | Prakash Kailasa | Sat Sep 7 19:42:08 2002 | -lp $t='(=[^=]+=|(?<=[*-/])-\d+|\d+)';sub r{for$o(qw|*/ -+|){1while s~$t([$o])$t~$_="$1 $3 $2";y/=//d;"=$_="~e}$_}s/\s//g;1while s~\(([^()]+)\)~$_=$1;r~e;r;y/=//d |
| 162.78 | Jasvir Nagra | Fri Sep 6 02:18:28 2002 | -lp use overload'""',sub{$_[0][0]},neg,sub{bless[-$_[0][0]]},map{my$z=$_;$_,sub{bless["@_[$_[2],!$_[2]] $z"]}}qw!+ - * /!;s/-/- /g;s/0*(\d+)/bless([$1])/g;$_=eval
|
| 163.69 | Prakash Kailasa | Thu Sep 5 19:02:34 2002 | -lp $t='(=[^=]+=|(?<=[*-/])-\d+|\d+)';sub r{for$o(qw|*/ -+|){1while s~$t([$o])$t~$_="$1 $3 $2";y/=//d;"=$_="~e}$_}s/\s+//g;1while s~\(([^()]+)\)~$_=$1;r~e;r;y/=//d |
| 163.69 | Michael Thelen | Wed Sep 4 02:44:40 2002 | -lp s/\s//g;s@(\()|(\))|(?<=[\d)])([-+])|[*/]@$".($1?$s!~s/^/(/:$2?$s=~s/(.*?)\(//&&$1:($x=$&,$z=!$3&&"+-",$s=~s/^[^($z]*/$x /,$&)).$"@eg;$_=join$","$_ $s"=~/\S+/g |
| Slowly inching my way toward 12th place... | |||
| 163.82 | TheodoreYoung | Tue Sep 3 18:17:52 2002 | -l sub n{my$c=shift;bless\$c}use overload'""',sub{${$_[0]}},'neg',sub{n "-$_[0]"},'nomethod',sub{n "@_[0,1,3]"};$_=<STDIN>;s/(-?)[0\s]*(\d+)/ $1 n($2)/g;print eval |
| There is a perl bug here. bless shift workds on Windows 5.6.1 but not on redhat 5.6.0 | |||
| 164.71 | Alain "TopMach" Dupuis | Thu Sep 5 22:04:04 2002 | -lp $_=join' ',/\d+|\S/g;s#(^|[^)\d] )- #$1-#g;sub z{$_=pop;for$o('*/','+-'){1while s!(\S+) ([$o]) (\S+)!"$1s$3s$2"!e}$_}1while s#\( ([^(]+?) \)#z$1#e;$_=z$_;y!s! ! |
| 165.25 | Jukka Suomela | Sun Sep 1 23:03:40 2002 | -p s//ac/;s/\s//g;1while s,(a.*)c(-?\d+),$2 $1 ,||s,(a.*)(([*/])|[-+])( (?(3)[-+*/]|[-+])),$2 $1$4,||s, ([-+*/]),$1c,||s,c\(,dc,||s,d \), ,||s,(a.*)(.),$2 $1,;s/ a// |
| 165.45 | tinzo (berlin.pm) | Fri Sep 6 11:09:59 2002 | -pl $*='(\w+)';$/='([()+-]|^|$)';1while s/\($*\)|\s/$+/|s#([^\d)])(-\d+)|$/$*(([*/])$*|([+-])$*$/)#"$1$3_".(push@/,$5?"$4 $7$9 $6$8":$+).$10#e;1while s#_$*#$/[$+-1]# |
| Still not short enough... | |||
| 165.65 | Alain "TopMach" Dupuis | Fri Sep 6 02:59:48 2002 | -lp $_=join' ',/\d+|\S/g;$q=/\(/?1:0,s#(\( ){$q}([^()]+)( \)){$q}#$_=$2;s!(^| \D )- !$1-!g;for$o('*/','+-'){1while s!(\S+) ([$o]) (\S+)!$1S$3S$2!}$_#ewhile/ /;y!S! ! |
| 165.68 | Eugene van der Pijll | Thu Sep 5 15:56:55 2002 | -lp s/\s+//g;s/((?<!\)|\d)-)?\d+/a$&z/g;sub w{1while s#z([@_])a(.*?)z# $2 $1z#}sub f{local $_=pop;1while s#\(([^()]+)\)#a.f($1).z#e;w('*/');w('-+');y/az//d;$_}$_=f$_
|
| 165.69 | Alain "TopMach" Dupuis | Thu Sep 5 01:38:47 2002 | -lp @a=/\d+|\S/g;$_="@a";s#(^|[(/*+-] )- #$1-#g;sub z{$_=pop;for$o('*/','+-'){1while s!(\S+) ([$o]) (\S+)!"$1s$3s$2"!e}$_}1while s#\( ([^(]+?) \)#z$1#e;$_=z$_;y!s! ! |
| 165.75 | Keith Calvert Ivey | Sat Sep 7 03:37:21 2002 | -p s/\s//g;$_="($_)";for(/(?<![\d)])-?\d+|./g){if(/[^(\d]$/){$r=/\)/?'^(':'*/'.'+-'x/[+-]/;push@o,pop@_ while"@_"=~/[$r]$/}/\)/?pop@_:push@{/\w/?\@o:\@_},$_}$_="@o
" |
| 166.56 | Michael Thelen | Wed Sep 4 02:12:00 2002 | -p s/\s//g;s@(\()|(\))|(?<=[\d)])([-+])|[*/]@$/.($1?!($s="$& $s"):$2?$s=~s/(.*?)\(//&&$1:($x=$&,$z=!$3&&"+-",$s=~s/^[^($z]*/$x /,$&)).$/@eg;$_.="
$s";$_="@{[split]}
" |
| Yet a few more strokes shaved... | |||
| 166.70 | Prakash Kailasa | Thu Sep 5 18:53:13 2002 | -lp $t='(=[^=]+=|(?<=[*-/])-\d+|\d+)';sub r{for$o(qw|*/ -+|){1while s~$t([$o])$t~$_="$1 $3 $2";y/=//d;"=$_="~e}$_}s/\s+//g;1while s~\(([^()]+)\)~$_=$1;r~e;$_=r;y/=//d |
| 167.22 | Jukka Suomela | Sun Sep 1 23:00:15 2002 | -p s//ac/;s/\s//g;1while s,(a.*)c(-?\d+),$2 $1 ,||s,(a.*)(([*/])|[-+])( (?(3)[-+*/]|[-+])),$2 $1$4,||s, ([-+*/]),$1c,||s,c\(,dc,||s,d \), ,||s,(a.*)(.) ,$2 $1 ,;s/ a// |
| 168.27 | Amir Karger | Fri Sep 6 15:45:44 2002 | -pl s/\s//g;
$p=qr/\((?:(?>[^()]+)|(??{$p}))*\)/;
$z=qr/$p|-?\d+/;
s#(?<=\S)([*/])($z)# $2 $1#g,
s#((?<=[\d)*/])[+-])($z( $z [*/])*)# $2 $1#gwhile($q++<1e4);
s/[()]//g;
|
| That was a whole lot of work to go through for a measly two spots in the rankings... For some reason this scores 174.29 when i test it. Hopefully PGAS isn't missing something. | |||
| 169.66 | Alain "TopMach" Dupuis | Fri Sep 6 01:42:40 2002 | -lp $_=join' ',/\d+|\S/g;s#(^|[^)\d] )- #$1-#g;$q=/\(/?1:0,s#(\( ){$q}([^()]+)( \)){$q}#$t=$2;for('*/','+-'){1while$t=~s!(\S+) ([$_]) (\S+)!$1S$3S$2!}$t#ewhile/ /;y!S! ! |
| 169.71 | Michiel van Leeuwen | Wed Sep 4 17:34:48 2002 | -pl s/\s//g;s%((?<=[(*+/-])-|^-)?\d+|.%$_="$& ";s/\( /$s=$_.$s;""/e;s/\) /$s=~s~(.*?)\( ~~;$1/e||s|^\D |$a="+-"x/[+-]/;$s=~s~[ */$a]*~~;$s=$_.$s;$&|e;$_%eg;$_.=$s;s/ $// |
| 2 simple optimizations gains me 9 strokes! | |||
| 171.54 | Mtv Europe | Wed Sep 4 17:41:16 2002 | -pl BEGIN{@^H{integer,binary}=(w)x2;sub
w{bless\$_[0]}use
overload'""',sub{${$_[0]}},neg,sub{w"-$_[0]"};for
my$i(qw(+ - * /)){*{"($i"}=sub{w"@_$i"}}$^H=16e4}s/-/
-/g;$_=eval
|
| who said dead horse? unfortunately changing ${$_[0]} to $${&w} doesn't work | |||
| 171.55 | Michael Thelen | Wed Sep 4 01:41:08 2002 | -p s/\s//g;s@(\()|(\))|(?<=[\d)])([-+])|[*/]@$/.($1?!($s="$& $s"):$2?$s=~s/(.*?)\(//&&$1:($x=$&,$z=" */".($3&&"+-"),$s=~s/^[$z]*/$x /,$&)).$/@eg;$_.="
$s";$_="@{[split]}
"
|
| A few strokes improvement. | |||
| 172.31 | Qingning Huo | Fri Sep 6 18:14:49 2002 | -p sub
p{push@o,$+}y/ ^I//d;{s/(\(+)?(-?\d+)//;p$_.=$1;while(s/^\)//||/^
/){p
while
s/([^(
])$//;chop}if(s/.//){$_.=$&;p
while!/[+-][*\/]$/&&s/([^(
])(?=.$)//;redo}}$_="@o
" |
| 172.39 | Jasper McCrea | Fri Sep 6 18:01:44 2002 | -lp sub
r{$_=pop;for$r(qw{?)(\+
)(&
)(\*|/}){$_="@_[0,2,1]"if@_=map
r($_),/(.*$r)(.+)/}y#&-/#a-j#;$_}s/\s//g;s#(\)|\d)-#$1&#g;1while
s#\(([^()]+)\)#r$1#e;$_=r$_;y#a-j#-'-/#
|
| tiebreaker fiddling (what's the point) and fix the tr bit. If I had more time, I might work on a different algorithm. | |||
| 172.59 | Jukka Suomela | Sun Sep 1 22:33:27 2002 | -pl s/^/ac/;s/\s//g;1while s,(a.*)c(-?\d+),$2 $1b,||s,(a.*)(([*/])|([-+]))(b(?(3)[-+*/]|[-+])),$2 $1$5,||s,b([-+*/]),$1c,||s,c\(,dc,||s,db\),b,||s,(a.*)(.)b,$2 $1b,;s/ ab// |
| 172.70 | Prakash Kailasa | Thu Sep 5 18:40:09 2002 | -lp $t=qr~=[^=]+=|(?<=[*-/])-?\d+|^\d+~;sub r{for$o(qw|*/ -+|){1while s~($t)([$o])($t)~$_="$1 $3 $2";y/=//d;"=$_="~e}$_}s/\s+//g;1while s~\(([^()]+)\)~$_=$1;r~e;$_=r;y/=//d |
| 173.62 | Andrew Savige | Thu Sep 5 04:28:48 2002 | -lp $_=" @{[/\d+|\S/g]}";s~(?<=[^\d)] -) ~~g;
/\d/&&($x.="$_ ",next),/\(/||($s=~s~.*?(?=[@{['-+'x/[*\/]/]}(]|$)~~,$x.=$&),
$s=/\)/?substr$s,2:"$_ $s"for/\S+/g;$_=$x.$s;chop
|
| *cough* This game is improving my regex knowledge. Variable width look-behind would be nice; I wonder if Larry is going to do that for Perl 6. | |||
| 173.68 | Jasper McCrea | Fri Sep 6 15:03:56 2002 | -lp sub r{$_=pop;for$r(qw{?)(\+ )(& )(\*|/}){$_="@_[0,2,1]"if@_=map{r($_)}/(.*$r)(.+)/}y#*-/&#a-g#;$_}s/\s//g;s#(\)|\d)-#$1&#g;1while s#\(([^()]+)\)#r$1#e;$_=r$_;y#a-g#*-/-#
|
| this is probably my last entry. teriffic. | |||
| 174.72 | Alain "TopMach" Dupuis | Wed Sep 4 23:15:39 2002 | -lp s/\s//g;sub z{$_=pop;s#(^|\W)-#$1_#g;for$o('*/','+-'){1while s!(\w+)([$o])(\w+)!$r=$2;$r=~y|*/+-|tdpm|;"$1s$3s$r"!e}$_}1while s#\(([^(]+?)\)#z$1#e;$_=z$_;y!mpdts_!-+/* -! |
| At last... | |||
| 175.40 | Michael Thelen | Mon Sep 2 17:44:09 2002 | -p s/\s//g;s@(\()|(\))|(?<=[\d)])([-+])|[*/]@$/.($1?($s="$&
$s")&&'':$2?$s=~s/(.*?)\(//s&&$1:($x=$&,$z="
*/".($3&&"+-"),$s=~s/^[$z]*/$x
/,$&)).$/@eg;$_.="
$s";$_="@{[split]}
" |
| Looking better, but it still feels way too verbose. Might be verbose, but it's working and you still have a whole week to trim it. Courage! | |||
| 175.48 | Mtv Europe | Tue Sep 3 14:03:13 2002 | -pl BEGIN{sub
w{bless\$_[0]}use
overload
neg,sub{w"-$_[0]"},'""',sub{${$_[0]}};
for
my$i(qw(+ - * /)){*{"($i"}=sub{w"@_$i"}}@^H{integer,binary}=(\&w)x2;$^H=16e4}s/-/
-/g;$_=eval
|
| sorry, i missed last stroke. mostly complete now. | |||
| 175.67 | Eugene van der Pijll | Thu Sep 5 15:51:13 2002 | -lp s/\s+//g;s/((?<!\)|\d)-)?\d+/a$&z/g;sub f{local$_=pop;1while s#\(([^()]+)\)#a.f($1).z#e;1while s#z([*/])a(.*?)z# $2 $1z#;1while s#z([-+])a(.*?)z# $2 $1z#;y/az//d;$_}$_=f$_ |
| Here are some solutions I thought up during work today. Let's see how far I can go with this. | |||
| 176.29 | Rick Klement | Sun Sep 1 16:52:25 2002 | -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/=/-/ |
| just to get on the board, so I don't have to go through that infinite selection list :) | |||
| 176.48 | Mtv Europe | Tue Sep 3 13:53:18 2002 | -pl BEGIN{sub
w{bless\$_[0]}use
overload
neg,sub{w"-$_[0]"},'""',sub{${$_[0]}};
for
my$i(qw(+ - * /)){*{"($i"}=sub{w"@_$i"}}@^H{integer,binary}=(\&w)x2;$^H=152e3}s/-/
-/g;$_=eval
|
| *twitch* | |||
| 176.64 | Jonathan Wang | Wed Sep 4 16:24:22 2002 | $_=<>;$_="($_)";y/ \t//d;s/\d+/ $& /g;s#([^ )])([+-]) #$1 $2#g;while(s#\(([^()]+)\)#$_=$1;foreach$a('/*','+-'){while(s! (\S+) ([$a]) (\S+) ! $1s$3s$2 !){}}$_#e){}y/s / /d;print
|
| 177.37 | Qingning Huo | Fri Sep 6 17:01:09 2002 | -p sub
p{push@o,$+}y!-+/* ^I!bBaA!d;{s/(\(+)?(b?\d+)//;p$_.=$1;while(s/^\)//||/^
/){p
while
s/(\w)$//;chop}if(s/.//){$x=$&;p
while
s/(a|$x)$//i;$_.=$x;redo}}$_="@o
";y!bBaA!-+/*! |
| 177.58 | Jed Davis | Tue Sep 3 18:40:11 2002 | -l sub n{my($x)=@_;bless\$x,'main'}use
overload(map{my$o=$_;$o,sub{n($_[2]?"$o$_[0]":"$_[0] $_[1] $o")}}qw{+
- * /}),'""',sub{${$_[0]}};$_=<>;s/-/- /g;s/\d+/n("$&")/g;print
eval |
| Never underestimate the power of code reuse. | |||
| 177.63 | Jonathan Wang | Wed Sep 4 15:45:07 2002 | $_=<>;$_="($_)";y/ \t//d;s/\d+/ $& /g;s#([*/+-])([+-]) #$1 $2#g;while(s#\(([^()]+)\)#$_=$1;foreach$a('/*','+-'){while(s! (\S+) ([$a]) (\S+) ! $1s$3s$2 !){}}$_#e){}y/s / /d;print
|
| 178.47 | Mtv Europe | Tue Sep 3 12:27:45 2002 | -pl BEGIN{sub
w{bless\$_[0]}use
overload
neg,sub{w"-$_[0]"},'""',sub{${$_[0]}};
for
my$i(qw(+ - * /)){*{"($i"}=sub{w"@_$i"}}@^H{integer,binary}=(\&w)x2;$^H|=151552}s/-/
-/g;$_=eval
|
| is it shorterst overload? | |||
| 178.63 | Andrew Savige | Thu Sep 5 03:35:35 2002 | -lp $_=" @{[/\d+|\S/g]}";s~(?<=^ -|[^\d)] -) ~~g;
/\d/&&($x.="$_ ",next),/\(/||($s=~s~.*?(?=[@{['-+'x/[*\/]/]}(]|$)~~,$x.=$&),
$s=/\)/?substr$s,2:"$_ $s"for split;$_=$x.$s;chop
|
| Just a pathetic regex tweak. I suck. | |||
| 178.69 | Prakash Kailasa | Thu Sep 5 18:30:03 2002 | -lp $t=qr~=[^=]+=|(?<=[*-/])-?\d+|^\d+~;sub r{$_=$1;for$o(qw|*/ -+|){1while s~($t)([$o])($t)~$_="$1 $3 $2";y/=//d;"=$_="~e}$_}s/\s+//g;1while s~\(([^()]+)\)~r~e;s~(.*)~r~e;y/=//d |
| 178.70 | Michiel van Leeuwen | Wed Sep 4 17:24:54 2002 | -pl s/\s//g;s%((?<=[(*+/-])-|^-)?\d+|.%$_="$& ";s/\( /$s=$_.$s;""/e;s/\) /$s=~s~(.*?)\( ~~;$1/e||s|[*+/-] |$a="+-"x/[+-]/;$s=~s~[ */$a]*~~;$s=$_.$s;$&|e;$b.=$_%eg;$_=$b.$s;s/ $// |
| More regex'es | |||
| 179.69 | Jonathan Wang | Wed Sep 4 15:39:45 2002 | $_=<>;$_="($_)";y/ \t//d;s/\d+/m$&m/g;s#([*/+-])([+-])m#$1m$2#g;while(s#\(([^()]+)\)#$_=$1;foreach$a('/*','+-'){while(s!m([^m]+)m([$a])m([^m]+)m!m$1 $3 $2m!){}}$_#e){}s/m//g;print
|
| 179.72 | Amir Karger | Fri Sep 6 05:09:46 2002 | -pl @a=qw(+- */);s/\s//g;do{push@c,$o[$l]||();($l%3>1&&(s/^\)//||s/^-?\d+/$f=push@c,$&;""/e))||($l%3>1&&s/^\(//||!$f||($o[$l]=s#^[$a[$l%3]]##&&$&))&&($l+=2,$f=0)}while$l--;s/$/@c/
|
| A last (pathetic) gasp? | |||
| 181.40 | tinzo (berlin.pm) | Thu Sep 5 23:18:43 2002 | -pl $w='(\w+)';$/='([()+-]|^|$)';$e='push@_,$3?"$2 $5$7 $4$6":$2;"$1_$#_$8"';1 while s/(\($w\)|\s)/$2/|s/([^\d)])(-\d+)/$e/ee|s#$/$w(([*/])$w|([+-])$w$/)#$e#ee;1 while s/_$w/$_[$+]/ |
| 181.69 | Jonathan Wang | Wed Sep 4 14:36:12 2002 | $_=<>;$_="($_)";s/[ \t]//g;s/\d+/=$&=/g;s#([*/+-])([+-])=#$1=$2#g;while(s#\(([^()]+)\)#$_=$1;foreach$a('/*','+-'){while(s!=([^=]+)=([$a])=([^=]+)=!=$1 $3 $2=!){}}$_#e){}s/=//g;print
|
| 182.57 | Andrew Savige | Wed Sep 4 12:13:48 2002 | -lp $_="@{[/\d+|\S/g]}";s~(?<=[^\d)] -) ~~g;s~^- ~-~;
/\d/&&($x.=$_.$",next),$:='-+'x/[*\/]/,
/\(/||($s=~s~.*?(?=[$:(]|$)~~,$x.=$&),
$s=/\)/?substr$s,2:"$_ $s"for split;$_=$x.$s;chop
|
| Come on Keith! | |||
| 182.69 | Jonathan Wang | Wed Sep 4 08:57:05 2002 | $_=<>;$_="($_)";s/[ \t]//g;s/\d+/=$&=/g;s#([*/+-])([+-])=#$1=$2#g;while(s#\(([^()]+)\)#$_=$1;foreach$a('/*','+-'){while(s!=([^=]+)=([$a])=([^=]+)=!=$1 $3 $2=!){}}$_#e){}s/=//g;print;
|
| 182.73 | Amir Karger | Fri Sep 6 04:07:13 2002 | -pl @a=qw(+- */);s/\s//g;do{push@c,$o[$l]||();if($l%3>1&&s/^((\))|-?\d+)//){$f=push@c,$1if!$2}elsif($l%3>1&& s/^\(//||!$f||($o[$l]=s#^[$a[$l%3]]##&&$&)){$l+=2;$f=0}}while$l--;s/$/@c/
|
| Still don't know why my 159 solution failed... | |||
| 183.58 | John Williams | Tue Sep 3 20:13:56 2002 | -pl $_="( @{[m=(\d+|\S)\s*=g]} )";s/(?<![\d)] )- /-/g;sub i{local$_=pop;s=(\S+) ([*/]) (\S+)=$1,$3,$2=||s/(\S+) ([+-]) (\S+)/$1,$3,$2/||y/() //d;$_}while(s/(\([^()]+\))/i$1/e){}y/,/ /
|
| 183.60 | Jukka Suomela | Sun Sep 1 22:24:02 2002 | -pl s/^/ac/;s/\s//g;1while s,(a.*)c(-?\d+),$2 $1b,||s,(a.*)([*/])(b[*/]),$2 $1$3,||s,(a.*)([-+*/])(b[-+]),$2 $1$3,||s,b([-+*/]),$1c,||s,c\(,dc,||s,db\),b,||s,(a.*)(.)b,$2 $1b,;s/ ab// |
| 183.67 | Jonathan Wang | Wed Sep 4 08:50:26 2002 | $_=<>;s/.+/($&)/;s/[ \t]//g;s/\d+/=$&=/g;s#([*/+-])([+-])=#$1=$2#g;while(s#\(([^()]+)\)#$_=$1;foreach$a('/*','+-'){while(s!=([^=]+)=([$a])=([^=]+)=!=$1 $3 $2=!){}}$_#e){}s/=//g;print;
|
| First time good luck! | |||
| 184.66 | Jasper McCrea | Thu Sep 5 17:29:39 2002 | -lp sub r{$_=pop;for$r(qw{?)(\+ )(- )(\*|/}){$_=r($_[0]).$".r(pop).$".pop if@_=/(.*$r)(.*)/}y#-/*+#a-d#;$_}s/\s//g;s#(^|[^0-9)])-#$1~#g;1while s#\(([^()]+)\)#r$1#e;$_=r$_;y#a-d~#-/*+-#
|
| did somebody mention a dead horse? | |||
| 185.69 | Prakash Kailasa | Thu Sep 5 16:06:07 2002 | -lp $t=qr~=[^=]+=|(?<=[*-/])-?\d+|^\d+~;sub r{$_=$1;for$o(qw|*/ -+|){1while s~($t)([$o])($t)~$_="$1 $3 $2";y/=//d;"=$_="~e}$_}s/\s+//g;1while s~\(([^()]+)\)~r~e||s~($t(.$t)+)~r~e;y/=//d |
| 187.71 | Michiel van Leeuwen | Tue Sep 3 21:39:07 2002 | -pl s/\s//g;$_=~s%((?<=[(*+/-])-|^-)?\d+|.%$_="$& ";/\d/?$b.=$_:(/\(/?$s=$_.$s:(/\)/?do{$s=~s/(.*?)\( //;$b.=$1}:do{$a="+-"x/[+-]/;$s=~s/[ *\/$a]*//;$b.=$&;$s=$_.$s}))%eg;$_=$b.$s;s/\s$//
|
| That $a did the trick :-) | |||
| 189.65 | Jasper McCrea | Thu Sep 5 14:37:59 2002 | -lp sub r{$_=pop;for$r(qw{+?)(\+ *)(- *)(\*|/}){if(@_=/(.$r)(.*)/){$_=r($_[0]).$".r(pop).$".pop}}y#-/*+#a-d#;$_}s/\s//g;s#(^|[(*/+-])-#$1~#g;1while s#\(([^()]+)\)#r$1#e;$_=r$_;y#a-d~#-/*+-#
|
| I'd like to say this was my first solution. ( can't get that damn ))+(( soltion to work at all! ) | |||
| 190.58 | John Williams | Tue Sep 3 20:11:50 2002 | -pl $_="( @{[m=(\d+|\S)\s*=g]} )";s/(?<![\d)] )- /-/g;sub i{local$_=pop;s=(\S+) ([*/]) (\S+)=$1,$3,$2=||s/(\S+) ([+-]) (\S+)/$1,$3,$2/||s/. (\S+) ./$1/;$_}while(s/(\([^()]+\))/i$1/e){}y/,/ /
|
| 190.76 | Keith Calvert Ivey | Fri Sep 6 02:36:04 2002 | -p s/\s//g;$_="($_)";for(/(?<![\d)])-?\d+|./g){if(/\)/){@o=(@o,$_=pop@_)until/\(/;pop@o;next}if(/[^(\d]$/){$r='*/'.'+-'x/[+-]/;@o=(@o,pop@_)while"@_"=~/[$r]$/}push@{/\w/?\@o:\@_},$_}$_="@o
" |
| Still on the wrong path, but submitting this to at least pass Qingning Huo. | |||
| 191.45 | Qingning Huo | Thu Sep 5 18:33:25 2002 | -p y/ ^I//d;my@o;{s/^(\(+)?(-?\d+)//;$_.=$1;push@o,$2;while(s/^\)//||/^
/){push@o,$&while
s#[^(
]$##;chop}if(s/^.//){$_.=$&;push@o,$&while
s#[-+*/](?=[-+]$)##||s#[*/](?=[*/]$)##;redo}}$_="@o
" |
| 191.59 | Andrew Savige | Wed Sep 4 07:56:24 2002 | -lp $_="@{[/\d+|\S/g]}";s~(?<=[^\d)] -) ~~g;s~^- ~-~;
$x.="$_ "x/\d/,$s=/\(/.$s,/[\d(]/&&next,
$:='-+'x/[*\/]/,$s=~s~.*?(?=[$:1]|$)~~,$x.=$&,
$s=/\)/?substr$s,1:"$_ $s"for split;$_=$x.$s;chop
|
| I am shocked to go sailing gaily path Keith. | |||
| 192.39 | Michael Thelen | Mon Sep 2 16:55:48 2002 | -p s/\s//g;s/(?<![\d)])-/~/g;s@(\()|(\))|([-+])|([*/])@$/.($1?($s="$&
$s")&&'':$2?$s=~s/(.*?)\(//s&&$1:($x=$&,$z="
*/".($3&&"+-"),$s=~s/^[$z]*/$x
/,$&)).$/@eg;$_.="
$s";$_="@{[split]}
";y/~/-/ |
| 193.48 | Markus Laire | Sun Sep 1 10:21:01 2002 | -pl %w=split//,'*b/c+d-e';sub r{my($a)=@_;
for$b('*/','+-'){1 while$a=~s#(\w+)([$b])(\w+)#a$1a$3a$w{$2}#}$a}
s/\s//g;s/(?<!\d|\))-/f/g;1 while s/\(([^()]+)\)/r$1/e;
$_=r$_;y#a-f# */+-#s;s/^\s// |
| Easy optimizations, score <200 | |||
| 194.68 | Prakash Kailasa | Wed Sep 4 21:16:10 2002 | -lp sub r{$_=$1;for$o(qw|*/ -+|){1while s~($t)([$o])($t)~$_="$1 $3 $2";y/{}//d;"{$_}"~e}$_}$t=qr~(?:^|(?<=[-+*/]))-?\d+|{[^}]+}~;s/\s+//g;1while s~\(([^()]+)\)~r~e||s~($t([-+*/]$t)+)~r~e;y/{}//d |
| 195.42 | Qingning Huo | Thu Sep 5 18:24:09 2002 | -p y/ ^I//d;my@o;{s/^(\(+)?(-?\d+)//;$_.=$1;push@o,$2;while(s/^\)//||/^
/){push@o,$&while
s#[^(
]$##;chop}if(s/^.//){$_.=$&;push@o,$1while
s#([-+*/])([-+])$#$2#||s#([*/])([*/])$#$2#;redo}}$_="@o
" |
| 195.75 | Keith Calvert Ivey | Sun Sep 1 21:57:06 2002 | -p s/\s//g;$_="($_)";for(/(?<![\d)])-?\d+|./g){if(/\)/){@o=(@o,$_=pop@_)until/\(/;pop@o;next}if(/[*\/+-]$/){$r='*/'.'+-'x$&=~/[+-]/;@o=(@o,pop@_)while"@_"=~/[$r]$/}push@{/\w/?\@o:\@_},$_}$_="@o
" |
| 197.43 | Qingning Huo | Thu Sep 5 18:11:32 2002 | -p y/ ^I//d;my@o;while(s/^(\(+)?(-?\d+)//){$_.=$1;push@o,$2;while(s/^\)//||/^
/){push@o,$&while
s#[^(
]$##;chop}s/^.//||last;$_.=$&;push@o,$1while
s#([-+*/])([-+])$#$2#||s#([*/])([*/])$#$2#}$_="@o
" |
| 197.78 | Andrew Savige | Wed Sep 4 04:52:42 2002 | -lp $_="@{[/\d+|\S/g]}";s~(?<=[^\d)] -) ~~g;s~^- ~-~;map{$x.="$_ "x/\d/;$s=/\(/.$s;$s=~s~(.*?)1~~,$x.=$1if/\)/;$s=~s~.*?(?=[@{['-+'x/[*\/]/]}1]|$)~~,$x.=$&,$s="$_ $s"if!/[\d()]/}split;$_=$x.$s;chop
|
| To my great surprise and delight, I have almost caught Keith! I am sure he will spurt away from me, however. | |||
| 198.55 | John Williams | Tue Sep 3 16:35:50 2002 | -pl @x=m=(\d+|[()+/*-])\s*=g;$_="( @x )";sub i{local$_=pop;s=(\S+) ([*/]) (\S+)=$1,$3,$2=||s/(\S+) ([+-]) (\S+)/$1,$3,$2/||s/. (\S+) ./$1/;$_}s/(?<![0-9)] )- /-/g;while(s/(\([^()]+\))/i$1/e){}y/,/ /
|
| Under 200! | |||
| 198.68 | Prakash Kailasa | Wed Sep 4 20:20:57 2002 | -lp sub r{$_=$1;for$o(qw|*/ -+|){1while s~($t)([$o])($t)~y/{}//dfor@x=($1,$3,$2);"{@x}"~e};$_}$t=qr~(?:^|(?<=[-+*/]))-?\d+|{[^}]+}~;s/\s+//g;1 while s~\(([^()]+)\)~r~e||s~($t([-+*/]$t)+)~r~e;y/{}//d |
| 200.77 | Keith Calvert Ivey | Sun Sep 1 20:52:40 2002 | -p s/\s//g;for(/(?<![\d)])-?\d+|./g){if(/\)/){@o=(@o,$_=pop@_)until/\(/;pop@o;next}if(/[*\/+-]$/){$r='*/'.'+-'x$&=~/[+-]/;@o=(@o,pop@_)while"@_"=~/[$r]$/}push@{/\w/?\@o:\@_},$_}$_="@{[@o,reverse@_]}
" |
| Bleah! Still disgusting. | |||
| 203.63 | Eike Grote | Thu Sep 5 20:18:03 2002 | -lp s/\s//g;s/(?<![)\d])-/y/g;$_="($_)";while(/\(/){eval($w='$z[$=++]="$2 $4 $3"while s|(\([^()]*?)(\w+)([*/])(\w+)([^()]*\))|$1x$=$5|');$w=~s|\*/|-+|;eval$w;s/\((\w+)\)/$1/}s/x$=/pop@z/e&y/y/-/while--$= |
| 205.69 | Prakash Kailasa | Wed Sep 4 13:26:11 2002 | -lp sub n{y/{}//dfor@x=($1,$3,$2);"{@x}"}sub r{$_=$1;for$o(qw|*/ -+|){1while s~($t)([$o])($t)~n~e};$_}$t=qr~(?:^|(?<=[-+*/]))-?\d+|{[^}]+}~;s/\s+//g;1while s~\(([^()]+)\)~r~e||s~($t([-+*/]$t)+)~r~e;y/{}//d |
| Just double the leaders' score. Should be a reasonable starting point ;-) | |||
| 205.77 | Michael Thelen | Sun Sep 1 21:17:13 2002 | -ln s/\s//g;/\d/?push@g,$_:/\)/?($f=pop@s)ne'('&&push(@g,$f)&&redo:(/([+-])|[*\/]/&&($z="*/".($1&&"+-"),"@s"=~/[$z]$/)&&push(@g,pop@s)&&redo,push@s,$_)for/(?:(?<![\d)])-)?\d+|./g;push@g,reverse@s;print"@g" |
| 206.56 | Greg Allen | Fri Sep 6 02:44:17 2002 | -pl sub a{$_=$1;0while s/\(([^()]+)\)/$0[++$-]=&a;"%$-"/e;s&([^+^I]*\d)([*/])([^+^I]+)&a(" $3 $2")⪚$_=a(" $' $2")if/^(.+)([+^I])/;"$_@_";}s/\s//g+s/(\d|\))-/$1^I/g+s/(.*)/a/e;s/%(\d+)/$0[$1]/ewhile/%/+y/^I/-/
|
| sub 200 would be tolerable | |||
| 206.70 | me ELOISE | Sat Sep 7 03:38:31 2002 | -l chomp($_=<>);$_="($_)";1while s!\(\s*([^(]+?)\)!$a=$1;map{1while$a=~s#((^|[*/+-]\s*)(-))?\s*(\w+)\s*([$_])\s*(-?)\s*(\w+)\s*#$h{A.++$i}="$3$4 $6$7 $5";"$2A$i"#e}'*/','-+';$a!e;1while s|A\d+|$h{$&}|;print |
| 207.57 | Greg Allen | Fri Sep 6 02:22:49 2002 | -pl sub a{$_=$1;0while s/\(([^()]+)\)/$0[++$-]=&a;"%$-"/e;s&([^+^I]*\d)([*/])([-%\d]+)&a(" $3 $2")⪚$_=a(" $' $2")if/^(.+)([+^I])/;"$_@_";}s/\s//g+s/(\d|\))-/$1^I/g+s/(.*)/a/e;s/%(\d+)/$0[$1]/ewhile/%/+y/^I/-/
|
| sub 200 would be tolerable | |||
| 207.58 | Andrew Savige | Wed Sep 4 00:25:17 2002 | -lp $_="@{[/\d+|\S/g]}";s;(?<=[^\d)] -) ;;g;s;^- ;-;;map{
$x.="$_ "x/\d/;$s=/\(/.$s;$s=~s/(.*?)1//,$x.=$1if/\)/;
if(/[-+*\/]$/){$s=~s/..//,$x.=$&while$s&&$s<1&$s=~/^[-+]/<=//;$s="$_ $s"}
}split;$_=$x.$s;chop
|
| Still flogging the same horse. Just one dirty trick after another (the latest being the default regex). I still think Mtv's Lemma holds the key to this game. Like Rick's Troppo Sort game, I suspect (from the leaderboard turnaround times) that the leaders are using a much slower algorithm than mine. | |||
| 209.69 | nashdj | Sun Sep 1 10:37:43 2002 | -l $e=qr{(??{$t})(([+-])(??{$t})(?{push@_,$2}))*};$t=qr{(??{$f})(([*/])(??{$f})(?{push@_,$2}))*};$f=qr{\((??{$e})\)|((-|)\d+)(?{push@_,$1})};$_=<>;s/ |\t//g;1while(s/\(\(([^)])\)\)/($1)/);$_=~$e;$,=' ';print@_ |
| temporary HACK to avoid segfault on linux | |||
| 210.77 | Ala Qumsieh | Tue Sep 3 21:13:23 2002 | -pl s/\s//g;%p=qw|* 2 / 2 + 1 - 1|;/\d/?push@_,$_:/\(/?push@@,$_:/\)/?do{push@_,$*while'('ne($*=pop@@)}:do{push@_,pop@@while$p{$@[-1]}>=$p{$_};push@@,$_}for/(?<=[\d)])[*\/+-]|-?\d+|./g;@_=(@_,reverse@@);$_="@_"
|
| Next submission on a different horse. Promise! | |||
| 213.53 | John Williams | Tue Sep 3 07:23:02 2002 | -pl @x=m=(\d+|[()+/*-])\s*=g;$_="( @x )";sub i{local$_=shift;s=(\S+) ([*/]) (\S+)=$1,$3,$2=||s/(\S+) ([+-]) (\S+)/$1,$3,$2/;"( $_ )"}s/(?<![0-9)] )- /-/g;while(/ /){s/\( (\S+) \)/$1/||s/\( ([^()]+) \)/i$1/e}y/,/ /
|
| test 44 took over an hour before I eliminated $& from my code | |||
| 213.70 | Michiel van Leeuwen | Tue Sep 3 21:29:43 2002 | -pl s/\s//g;$_=~s%((?<=[(*+/-])-|^-)?\d+|.%$_="$& ";/\d/?$b.=$_:(/\(/?$s=$_.$s:(/\)/?do{$s=~s/(.*?)\( //;$b.=$1}:do{/[+-]/?do{$s=~s/[ *\/+-]*//;$b.=$&}:do{$s=~s/[ *\/]*//;$b.=$&};$s=$_.$s}))%eg;$_="$b$s";s/\s$// |
| Aargh. those egative integers... And why took I so long before using google? | |||
| 214.46 | Qingning Huo | Thu Sep 5 18:02:54 2002 | -p y/ ^I//d;my@o;while(s/^(\(+)?(-?\d+)//){$_.=$1;push@o,$2;while(s/^\)//){push@o,$&while
s#[^(
]$##;chop}s/^.?//||last;$_.=$&;push@o,$1while
s#([-+*/])([-+])$#$2#||s#([*/])([*/])$#$2#}push@o,$&while
s/.$//;$_="@o
" |
| 214.82 | Jasvir Nagra | Thu Sep 5 22:23:59 2002 | -lp sub r{bless["@_[$_[2],!$_[2]] $_[3]"]};use overload'+'=>sub{r@_,'+'},'-'=>sub{r@_,'-'},'*'=>sub{r@_,'*'},'/'=>sub{r@_,'/'},'""'=>sub{$_[0][0]},neg=>sub{bless[-$_[0][0]]};s/0*(\d+)/bless([$1])/g;s/-/ -/g;$_=eval
|
| 216.69 | me ELOISE | Tue Sep 3 03:48:29 2002 | -l chomp($_=<>);$_="($_)";1while s!\(\s*([^(]+?)\)!$a=$1;map{1while$a=~s#((^|[*/+-]\s*)(-))?\s*([A0-9]+)\s*([$_])\s*(-?)\s*([A0-9]+)\s*#$h{A.++$i}="$3$4 $6$7 $5";$2."A$i"#e}'*/','-+';$a!e;1while s|A\d+|$h{$&}|e;print |
| 216.79 | Ala Qumsieh | Tue Sep 3 20:08:25 2002 | -pl %p=qw|* 2 / 2 + 1 - 1|;s/\s//g;/\d/?push@_,$_:/\(/?push@@,$_:/\)/?do{push@_,$*while@@&&'('ne($*=pop@@)}:do{push@_,pop@@while$p{$@[-1]}>=$p{$_};push@@,$_}for/(?<=[\d)])[*\/+-]|-?\d+|./g;push@_,pop@@while@@;$_="@_" |
| dead horse, I know. At least I'm ahead of /-\ ;) | |||
| 218.57 | Greg Allen | Fri Sep 6 00:56:10 2002 | -pl sub a{$_=$1;0while s/\(([^()]+)\)/$0[++$-]=&a;"%$-"/e;s&([^+^I]+)([*/])([-%\d]+)&$0[++$-]=a(" $3 $2");"%$-"⪚$_=a(" $' $2")if/(.+)([+^I])/;"$_@_"}s/\s//g+s/(\d|\))-/$1^I/g+s/(.*)/a/e;s/%(\d+)/$0[$1]/ewhile/%/|y/^I/-/
|
| I see the light | |||
| 218.60 | Andrew Savige | Tue Sep 3 13:25:09 2002 | -lp $_="@{[/\d+|\S/g]}";s;(?<=[^\d)] -) ;;g;s;^- ;-;;map{
$x.="$_ "x/\d/;$s=Y x/\(/.$s;$s=~s/(.*?)Y//,$x.=$1if/\)/;
if(/[-+*\/]$/){$s=~s/..//,$x.=$&while$s&&$s=~/^[-+]/<=/[-+]/&$s!~/^Y/;$s="$_ $s"}
}split;$_=$x.$s;chop
|
| *Cough* there were a lot of blunders in my earlier efforts. And plenty more remain. Kept my original algorithm, just corrected some blunders and changed from array-based to string-based. | |||
| 220.68 | me ELOISE | Tue Sep 3 03:21:58 2002 | -l chomp($_=<>);$_="($_)";1while s!\(\s*([^(]+?)\)!$a=$1;for$b('*/','-+'){1while $a=~s#((^|[*/+-]\s*)(-))?\s*([A0-9]+)\s*([$b])\s*(-?)\s*([A0-9]+)\s*#$h{A.++$i}="$3$4 $6$7 $5";$2."A$i"#e}$a!e;1while s|A\d+|$h{$&}|e;print |
| 222.58 | Greg Allen | Fri Sep 6 00:03:35 2002 | -pl sub a{$_=$1;0while s/\(([^()]+)\)/$0[++$-]=&a;"%$-"/e;s&([^+~]+)([*/])([-%\d]+)&$0[++$-]=a(" $3 $2");"%$-"⪚s/(.+)([+~])(.+)/a(" $3 $2")/e;$_.="@_"}s/\s//g;s/(\d|\))-/$1~/g;s/(.*)/a/e;s/%(\d+)/$0[$1]/ewhile/%/|y/~/-/
|
| nearly down to double figures :) | |||
| 224.79 | Ala Qumsieh | Tue Sep 3 16:08:26 2002 | -pl %p=qw|* 2 / 2 + 1 - 1|;s/\s//g;map{/\d/?push@_,$_:/\(/?push@@,$_:/\)/?do{push@_,$*while@@&&'('ne($*=pop@@)}:do{push@_,pop@@while$p{$@[-1]}>=$p{$_};push@@,$_}}m:\b[*/+-]|(?<=\))[*/+-]|-?\d+|.:g;push@_,pop@@while@@;$_="@_"
|
| As usual, start with the brute force approach. | |||
| 225.72 | Amir Karger | Fri Sep 6 02:35:48 2002 | -pl @a=qw(+- */);
s/\s//g;
do{push@c,$o[$l]||();if($l%3==2&&s/^(\)|(-?\d+))//){$l--;if(defined$2){push@c,$2;$found=1}}elsif($l%3==2&&s/^\(//||!$found||($o[$l]=s#^[$a[$l%3]]##&&$&)){$l++;$found=0}else{$l--}}until$l==-1;s/$/@c/
|
| New algorithm. Hopefully this one will work on your computers too! | |||
| 226.53 | Qingning Huo | Thu Sep 5 16:06:42 2002 | -p y/ ^I//d;my@o;while($.&&s/^-?\d+//||s/^.//){if($.=!($&=~y/0-9)//)){$_.=$&;push@o,$1while
s#([-+*/])([-+])$#$2#||s#([*/])([*/])$#$2#}elsif($&eq')'){push@o,$&while
s#[^(
]$##;chop}else{push@o,$&}}push@o,$&while s/.$//;$_="@o
" |
| 227.80 | Mtv Europe | Sun Sep 1 14:45:27 2002 | -pl BEGIN{$OVERLOAD{d}++;*{'()'}=sub{};eval"*{'($_'}=sub{bless\\\"\@_$_\",main}"for
qw(+ - * /);*{'(neg'}=sub{bless\"-$_[0]",main};*{'(""'}=sub{${$_[0]}};$^H{integer}=$^H{binary}=sub{bless\$_[0],main};$^H|=151552}s/--/-
-/;$_=eval
|
| abuse of perl hmm .. another (ab)use of overload | |||
| 233.70 | me ELOISE | Tue Sep 3 02:26:15 2002 | -l chomp($_=<>);$_="($_)";1while s!\(([^(]+?)\)!$a=$1;$a=~s#\s*((^|[*/+-])\s*)-\s*#$1=#g;for$b('*/','-+'){1while$a=~s#\s*(=?[A0-9]+)\s*([$b])\s*(=?[A0-9]+)\s*#$h{A.++$i}="$1 $3 $2";"A$i"#e}$a!xe;1while s|(A\d+)|$h{$1}|e;s/=/-/g;print |
| at least I'm getting near the ballpark | |||
| 244.60 | Andrew Savige | Tue Sep 3 07:02:19 2002 | -n $_="@{[/\d+|\S/g]}";s;(?<=[^\d)] -) ;;g;s;^- ;-;;map{
/\d/?push@o,$_:/\(/&&unshift@~,Y;if(/\)/){push@o,$:while($:=shift@~)!~Y}
if(/[-+*\/]$/){push@o,shift@~while@~&&$~[0]=~/[-+]/<=/[-+]/&$~[0]!~Y;@~=($_,@~)}
}/-?\d+|\S/g;push@o,@~;print"@o
"
|
| Dirty trick: changed '(' token to 'Y'. Since the actual letter is arbitrary, I naturally chose 'Y' to honour our esteemed referee, Dr `/anick Shampoo. | |||
| 253.50 | Andrew Savige | Tue Sep 3 00:43:36 2002 | -n $_="@{[/\d+|\S/g]}";s;([^\d)]) - ;$+ -;g;s;^- ;-;;
map{/\d/?push@o,$_:/\(/&&unshift@~,$_;
if(/\)/){push@o,$&while+shift(@~)=~/[^(]/}
if(/[-+*\/]$/){push@o,shift@~while@~&&$~[0]=~/[-+]/<=/[-+]/&$~[0]ne'(';@~=($_,@~)}
}/-?\d+|\S/g;
push@o,@~;print"@o
"
|
| Interesting problem (kudos to Juho), clumsy opening bid.
I think this is the first time I've ever used unshift in a
golf game (Ton would never approve ;) -- a sure sign something
is wrong. I wonder what The Aliens are doing? I expect they're
sitting around the campfire sucking hard on the Regex crack-pipe
chanting "Mtv's Lemma, Mtv's Lemma, Mtv's Lemma ...".
253, and it's not signed André? Oh my. (okay, I know it's not right to use of my ref status to gloat, but then again, power corrupts and all that :) ) | |||
| 266.69 | Greg Allen | Thu Sep 5 11:13:26 2002 | -pl sub t{$_=pop;s/\((.*)\)/a($1)/e;"$_@_"}$b=qr/\((?:(?>[^()]+)|(??{$b}))*\)/;$p=qr/$b|-?\d+/;sub p{$_=shift;/(\*|\/)($p)$/?p("$`",'',t(" $1@_",$2)):t@_,$_}sub a{$_=shift;/[\d)]([-+]($p(?:[*\/]$p)*))+$/&&/(.)(\Q$+\E)$/?a("$`",'',p($2," $1@_")):p$_,@_}y/ ^I//d;$_=a$_
|
| guess this approach won't get too close to 104 then... | |||
| 267.25 | Honza Pazdziora | Fri Sep 6 14:09:30 2002 | -n close STDERR;
s!(^|[(*/+-])\s*(-?)\s*(\d+)!$1 d("$2$3")!g;
$_=`$^X -MO=Deparse,-p -e'$_'`;
print map({
if (/\d/) {
' 'x($i++>0).$_;
} elsif (/\)/) {
$i++;shift@a;
} else {
/\(/?(unshift@a,''):($a[0]=" $_");();
}
}/-?\d+|[-*+\/()]/g),@a,'
' |
| The question is whether your machine won't break on the long -e option. Mine doesn't. | |||
| 276.71 | Greg Allen | Wed Sep 4 17:08:15 2002 | -pl sub t{$_=pop;/^\((.*)\)$/?a($1,@_):"$_@_"}$b=qr{\((?:(?>[^()]+)|(??{$b}))*\)};$p=qr{$b|-?\d+};sub p{$_=shift;/(\*|\/)($p)$/?p("$`",'',t(" $1@_",$2)):t@_,$_}sub a{$_=shift;/(?<=[\d)])(([-+])($p(?:[*\/]$p)*))+$/&&/(.)(\Q$+\E)$/?a("$`",'',p($2," $1@_")):p$_,@_}s/\s//g;$_=a$_
|
| parsing by regex still sucks | |||
| 278.34 | Markus Laire | Sun Sep 1 09:43:33 2002 | -p %w=('+'=>'a','-'=>'s','*'=>'M','/'=>'D');
sub rpn($) {
my($a)=@_;
1 while$a=~s#(\w+)([*/])(\w+)#_$1_$3_$w{$2}#;
1 while$a=~s/(\w+)([+-])(\w+)/_$1_$3_$w{$2}/;
$a
}
s/\s//g;s/(?<!\d|\))-/n/g;
1 while s/\(([^()]+)\)/rpn$1/e;
$_=rpn$_;
y#saMDn#-+*/-#;
y#_# #s;
s/^\s//;
$_.="\n"; |
| First working solution, so I don't bother with optimization yet. | |||
| 289.71 | Greg Allen | Wed Sep 4 16:45:19 2002 | -pl sub t{$_=shift;/^\((.*)\)$/?a($1,@_):"$_@_"}$b=qr{\((?:(?>[^()]+)|(??{$b}))*\)};sub p{$_=shift;/(\*|\/)($b|-?\d+)$/?p("$`",'',t($2," $1@_")):t $_,@_}$p=qr{(?:$b|-?\d+)};sub a{$_=shift;/(?<=[\d)])(([-+])($p(?:[*\/]$p)*))+$/&&/(.)(\Q$+\E)$/?a("$`",'',p($2," $1@_")):p$_,@_}s/\s//g;$_=a$_
|
| parsing by regex sucks | |||
| 290.48 | Keith Calvert Ivey | Sun Sep 1 15:37:22 2002 | $_=<>;s/\s//g;@s=/(?<![\d)])-?\d+|\S/g;L:for(@s){
/\w/and@o=(@o,$_),next;
/\(/and@_=(@_,$_),next;
if(/\)/){/\(/?next L:(@o=(@o,$_))while$_=pop@_;next}
if(/[+-]/){@o=(@o,pop@_)while@_&&$_[-1]!~/\(/}
if(/[*\/]/){@o=(@o,pop@_)while$_[-1]=~/[*\/]/}
/\S/&&push@_,$_
}@o=(@o,reverse@_);print"@o
" |
| Submitting my first working solution, for the record. Haven't shortened it at all yet, obviously. | |||
| 292.43 | Constantin M | Sat Sep 7 19:18:08 2002 | $s='-+*\/';
$d='-?\d+';
$_=<>;
s/\s+//g;
@_=(m/(^$d|(?<![$s(])[$s]|$d|.)/g);
while(~($_=shift@_)){
/\(/?$.++:/\)/?$.--:/$d/?$r.=$_.' ':/./?push@o,[$_,$.]:0;
$_=$_[0]||'';
while((/[$s)]$/||!@_ )&&@o&&$o[$#o][1]==$.&&!($o[$#o][0]=~/[-+]/&&/[*\/]/)){$r.=${pop@o}[0].' '}}
$_=$r;
s/\s$/\n/;
print
|
| 295.21 | Amir Karger | Wed Sep 4 19:57:25 2002 | -pl @a=qw(+- */);
sub e2r {
my $level = pop;
if ($level == 2) {
^Is/^\(// && &e2r x s/^\)// || s/-?\d+// && $&
} else {
^Imy $exp = &e2r($level+1);
^Iwhile (s#^[$a[$level]]##) {
^I my $op = $&;
^I $e2 = &e2r($level+1);
^I $exp .= " $e2 $op";
^I }
^I$exp;
}
}
s/\s+//g;
$_=e2r
|
| Minimal squeezing, but arithmetic & multiplicative expressions are almost the same, so shoehorn all three types into one subroutine that's called with a "level". | |||
| 316.87 | Peter Haworth | Fri Sep 6 18:46:57 2002 | -p $t='-?';s#\s##g;{if(s#^$t\d+##){$\.="$& "}elsif(s#^\(##){$n=$O.=$&}elsif(s#^\)##){$\.="$& "while$O=~s#[^(]$##;$O=~s#\($##}elsif(s#^[+-]##){$o=$&;$\.="$& "while$O=~s#[-+/*]$##;$n=$O.=$o}elsif(s#^[/*]##){$o=$&;$\.="$& "while$O=~s#[/*]$##;$n=$O.=$o}else{last}($t,$n)=$n&&'-?';redo}$\.="$o "while$o=chop$O;$\=~s/ $/
/
|
| This is feeble, but I've run out of time | |||
| 317.75 | me ELOISE | Mon Sep 2 15:54:39 2002 | -l sub g{my$t=pop;$t=~s|\s*((^\|[*/+-])\s*)-\s*|$1=|g;$t=~s|^\s*(-?\d+)\s*$|$h{A.++$i}=$1;"A$i"|ge;for$a('*/','-+'){$t=~s|\s*(=?[A0-9]+)\s*([$a])\s*(=?[A0-9]+)\s*|$h{A.++$i}="$1 $3 $2";"A$i"|ewhile$t=~/[$a]/}$t}chomp($_=<>);s|\(([^()]+)\)|$h{A.++$i}=g$1;"A$i"|gewhile/\(/;$_=g$_;s|(A\d+)|$h{$1}|while/A/;s|=|-|g;print |
| not sure why I'm bothering to refine this algorithm since I know it can't compete... | |||
| 322.75 | GONZO | Wed Sep 4 11:44:23 2002 | -l @s=@o=();%p=split//,'-1+1/2*2_3';($_=<>)=~s/\s//g;s/(^|[-+\/*(])-(\d+)/$1_$2/g;@l=split/([-+\/*()])/;for(@l){s/_/-/g;/\d/&&push@o,$_;/\(/&&push@s,$_;if(/\)/){while(defined($x=pop@s)and'('ne$x){push@o,$x}}if(/^[-+\/*]$/){while($p{$s[$#s]}>=$p{$_}){$x=pop@s;push@o,$x}push@s,$_}}while($x=pop@s){push@o,$x}print join' ',@o |
| Better than nothing... | |||
| 327.75 | Michael Thelen | Sun Sep 1 07:09:38 2002 | -ln0 s/\s//g;s!(^|[+/*-])-!$1~!g;@t=/[\(\)+\/*-]|~?\d+/g;for(@t){s/~/-/;/\d/?push(@g,$_):/\(/?push(@s,$_):/\)/?${$f=pop@s,($f ne'('&&(push(@g,$f),redo))}:/[+-]/?${$s[-1]=~/[\*\/+-]/&&($f=pop@s,push(@g,$f),redo);push@s,$_}:/[*\/]/?${$s[-1]=~/[\*\/]/&&($f=pop@s,push(@g,$f),redo);push@s,$_}:1}$f=pop@s,push@g,$f while@s;print"@g" |
| Holy moly, what an ugly drive. Now to hack my way out of the rough... | |||
| 395.72 | me ELOISE | Mon Sep 2 15:32:22 2002 | -l sub g{my$t=pop;$t=~s|\s*((^\|[*/+-])\s*)-\s*|$1=|g;$t=~s|^\s*(-?\d+)\s*$|$h{A.++$i}=$1;"A$i"|ge;$t=~s|\s*(=?[A0-9]+)\s*([*/])\s*(=?[A0-9]+)\s*|;$h{A.++$i}="$1 $3 $2";"A$i"|ewhile$t=~/[*\/]/;$t=~s|\s*(=?[A0-9]+)\s*([+\-])\s*(=?[A0-9]+)\s*|$h{A.++$i}="$1 $3 $2";"A$i"|ewhile$t=~/[+-]/;$t}chomp($_=<>);s|\(([^()]+)\)|$h{A.++$i}=g$1;"A$i"|gewhile/\(/;$_=g$_;s|(A\d+)|$h{$1}|while/A/;s|=|-|g;print |
| *sigh* ... at least I'm on the board... | |||
| 438.24 | Qingning Huo | Thu Sep 5 13:16:50 2002 | -lp s/\s//g;
$o=0;
@s=@o=();
while (/\S/) {
^I$o ? s/.// : s#-?\d+|\(##;
^I$n = $&;
^Iif ($n eq '(') {
^I^Ipush @s, $n;
^I^I$o = 0;
^I} elsif ($n eq ')') {
^I^Iwhile (($a=pop(@s)) ne '(') {
^I^I^Ipush @o, $a;
^I^I}
^I^I$o = 1;
^I} elsif ($n !~ m#\d#) {
^I^Iwhile (@s && $s[-1] ne '(' && ($s[-1] =~ m#[*/]# || $n =~ m#[-+]#)) {
^I^I^Ipush @o, pop @s;
^I^I}
^I^Ipush @s, $n;
^I^I$o = 0;
^I} else {
^I^Ipush @o, $n;
^I^I$o = 1;
^I}
}
while (@s) { push @o, pop @s; }
$_ = "@o"; |
| 472.29 | Peter Haworth | Wed Sep 4 19:32:43 2002 | -p
$t='-?';
s#\s##g;
{
if(s#^$t\d+##){
$\.="$& "
}elsif(s#^\(##){
$n=$ops.=$&
}elsif(s#^\)##){
while($ops=~s#[^(]$##){
$\.="$& "
}
$ops=~s#\($##
}elsif(s#^[+-]##){
$op=$&;
while($ops=~s#[-+/*]$##){
$\.="$& ";
}
$n=$ops.=$op
}elsif(s#^[/*]##){
$op=$&;
while($ops=~s#[/*]$##){
$\.="$& ";
}
$n=$ops.=$op
}else{
last
}
($t,$n)=$n&&'-?';
redo
}
$\.="$o "while$o=chop$ops;
$\=~s/ $/
/ |
| Even after golfing, this is still going to be too big | |||
| 589.25 | Peter Haworth | Tue Sep 3 17:31:26 2002 | -p
$t=1;
while(1){
s#^\s+##;
if($t && s#^-\s*0*(\d+)##){
$\.= "-$1 ";
}elsif(s#^0*(\d+)##){
$\.= "$1 ";
}elsif(s#^\(##){
push @ops,'(';
$n=1;
}elsif(s#^\)##){
while(($op=pop @ops) ne '('){
$\.= "$op ";
}
}elsif(s#^([+-])##){
$op=$1;
while(@ops && $ops[-1]=~m#[+-/*]#){
$\.= pop(@ops)." ";
}
push @ops,$op;
$n=1;
}elsif(s#^([/*])##){
$op=$1;
while(@ops && $ops[-1]=~m#[/*]#){
$\.= pop(@ops)." ";
}
push @ops,$op;
$n=1;
}else{
last;
}
($t,$n)=$n
}
($\.=join' ',reverse @ops)=~s/ ?$/
/;
|
| 693.32 | Amir Karger | Wed Sep 4 19:50:50 2002 | -nl
use strict;
s/\s+//g; # first get rid of whitespace
my $a = a2r();
print $a;
# arithmetic expression is mult. exp. followed by N pairs of
# arithmetic operator and mult. exp.
sub a2r {
my $mult = m2r();
while (s/^[+-]//) {
^Imy $op = $&;
^Imy $m2 = m2r();
^I$mult .= " $m2 $op";
}
$mult;
}
# multiplicative expression is unary exp. followed by N pairs of
# mult. operator and unary exp.
sub m2r {
my $unary = u2r();
while (s#^[*/]##) {
^Imy $op = $&;
^Imy $u2 = u2r();
^I$unary .= " $u2 $op";
}
$unary;
}
# Unary expression is integer or parenthesized arith. exp.
sub u2r {
if (s/^\(//) {
^Imy $a = a2r();
^Is/^\)//;
^I$a;
} else {
^Is/-?\d*//;
^I$&;
}
}
|
| I'm entering this contest against my better judgement. My eyeballs still ache from mushing them back in on August 8... | |||
| 1666.36 | André Savigne | Wed Sep 4 01:50:04 2002 | eval eval '"'.
'\\$_=\\"\\@\\{[<>=~/\\\\'.('`'|'$').'+|\\\\'.('{'^'(').'/'.('`'
|"'").']\\}\\";'.('['^'(').';(?<=[^\\\\'.('`'|'$').')]'.('{'^'['
).(( '-')
).(( ')')
).(# Ovian Joy `/anick Champoux '{'^
'{'^ '[')
.';' .';'
.''. ('`'
|"\'"). (';').(
'['^"\("). ';^-'.('{'
^'[').';-;;'. ('`'|('-')).(
'`'|'!').("\["^ '+').'\\{\\$'.(
'['^'#').'.=/\\'. '\\'.('`'|('$')).
('/?\\$_.\\$\\":'). "'"."'".';\\$,=/\\'
.'\\(/.\\$,;/\\\\)/' .'&&(\\$,=~'.(('[')^
'(').'/(.*?)'.("\^"^( '`'|"\/")).'//,\\$'.(
'['^"\#").'.=\\$+);'.( '`'|')').('`'|'&').'('
.'/[-+*\\\\/]\\$/)\\{'. '\\$,=~'.('['^'(').'/.'
.'.//,\\$'.('['^'#').'.' .'=\\$&'.('['^',').('`'|
'(').('`'|')').('`'|','). ('`'|'%').'\\$,&&\\$,<!'.
'\\$%&\\$,=~/^[-+]/<=//;' .'\\$,=\\"\\$_'.('{'^'[')
.'\\$,\\"\\}\\}/\\\\'.('{' ^'(').'+/'.('`'|"'").';\\'
.'$_=\\$'.('['^'#').'.\\$' .',;'.('['^'(').'/.\\$//;'
.('['^'+').('['^')').('`'|')').('`'|'.').('['^'/').'\\$_.\\$/"';
$:='.'^'~';$~='@'|'(';$^=')'^'[';$/='`'|'.';$_='('^'}';$,=('`');
|
| "Undies Clad Figure Trudging".
To mark the changing of the guard in Canadian golf.
Ala only needs to finish in 41st place to overtake
`/anick Champoux on the Career Money List.
And to celebrate the launch of the new "Ovian Joy"(R) range
of designer underwear by `/anick Champoux Fashion, Inc.
(R)"Ovian Joy" is a registered trademark of `/anick Champoux
Fashion, Inc. Used with permission.
And, of course, I had to be the one to ref that entry... Oh, the irony, the cruel irony of it... |
| Score | Golfer | Submit Time | Code |
| 141.36 | Rick Klement | Sat Sep 7 14:53:42 2002 | -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/ ^I//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! pretty :) | |||
| 142.35 | Rick Klement | Sat Sep 7 14:52:30 2002 | -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/ ^I//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! | |||
| 158.44 | Eugene van der Pijll | Thu Sep 5 23:20:42 2002 | -lpX use
base
B::Deparse;s/-/$:/g;s/\d+/a$&/g;sub
maybe_parens{$_=$_[1];s/ (.*) (.*)/ $2 $1/;y/ /_/;$_}$_=main->new->coderef2text(eval"sub{$_}");y/_
-';-}/ /d |
| 193.44 | TheodoreYoung | Tue Sep 3 16:03:52 2002 | -l package A;
use overload
'""'=>sub{${$_[0]}},
'neg'=>sub{n A "-$_[0]"},
'nomethod'=>sub{n A "@_[0,1,3]"};
sub n{my $c=$_[1];bless \$c}
$_=<STDIN>;
s/(-?)[0 ]*(\d+)/ $1 A->n($2)/g;
print eval; |
| Score | Golfer | Submit Time | Code |
| 17.37 | Taipei.pm | Sun Sep 1 13:34:21 2002 | -wle 'print %]'; |
| 111.75 | Ton Hospel | Mon Sep 2 02:57:31 2002 | -p s#(^|[*-/(])\s*(-?\s*\d+)#$1(bless[s!\$! $2!])#g;s/.?/"use overload '$&',sub{s!! $&!;shift}"/gee;eval$`;s/// |
| 113.75 | Ton Hospel | Mon Sep 2 02:50:14 2002 | -p s#(^|[*-/(])\s*(-?\s*\d+)#$1(bless[s!\$! $2!])#g;eval"$_;".s/./"use overload '$&',sub{s!! $&!;shift}"/gee;s/// |
| more regex repeating | |||
| 115.47 | Stephen Turner | Mon Sep 2 10:41:48 2002 | -p use
overload
nomethod,sub{bless[@{$_[0]},@{$_[1]},pop]};y/ ^I//d+s/(?<![\d)])-?\d+/(bless["$&"])/g;$_="@{eval
}
"
|
| We don't need to make the constructor explicit.
WARNING: Like my last program, this uses a lot of memory. Maybe even more than my last program. The memory usage is problematic, but it seems that even with the full 4 GB (allowed by the rules) of real memory this would be way too slow. | |||
| 115.76 | Ton Hospel | Mon Sep 2 02:38:49 2002 | -p s#(^|[*-/(])\s*(-?\s*\d+)#$1(bless[s!\$! $2!])#g;eval"$_;".s/./"use overload '$&',sub{s!\$! $&!;shift}"/gee;s/// |
| The output returned for '1 - - 2' is '1 - 2', but it should be something like '1 -2 -' | |||
| 116.66 | Stephen Turner | Mon Sep 2 13:08:08 2002 | -pl use
overload'""',sub{"@{$_[0]}"},nomethod,sub{bless\@_};y/ ^I//d+s/(?<![\d)])-?\d+/(bless["$&"])/g;$_=eval;y/ //s
|
| While my rude 115.47 is still pending, try this one, which is one stroke longer, but much more polite. This has now taken 15 minutes of CPU on a 750 MHz Athlon, which isn't swapping. Sorry, but I'll have to reject the solution. | |||
| 116.78 | Ton Hospel | Mon Sep 2 02:32:18 2002 | -lp s#(^|[*-/(])\s*(-?\s*\d+)#$1(bless[s!\$!$2 !])#g;eval"$_;".s/./"use overload '$&',sub{s!\$!$& !;shift}"/gee;chop |
| mm, the horse still is not dead | |||
| 120.62 | Chia-chi Yeh | Tue Sep 3 19:02:01 2002 | -pl s/\s//g;$_.=")";0while s!\(?([^()]*)\)!$a=$1;for(qw(*/ +-)){0while$a=~s#(\S)([$_])(.*?\S)([*/+-]|$)#$1 $3 $2$4#}$a!e |
| test 45 has not been completed after 20 minutes of execution in a Pentium Celeron at 300 MHz | |||
| 128.78 | Ton Hospel | Mon Sep 2 00:12:12 2002 | -lp s#(^|[-+*/(])\s*(-?\d+)#$1(bless[\$q.="$2 "])#g;s/./"use overload'$&',sub{\$q.='$& ';shift}"/eegfor$q="+-*/";eval;$_=$q;chop |
| Mmm, i'm starting to doubt this horse Unfortunaty (again), it fails the test with '1 - -\t2'. | |||
| 131.35 | pom | Mon Sep 2 11:11:04 2002 | -p $_="($_)";y/ ^I//d;s/\b/x/g;1while s!\(([^()]+)\)!$_=$1;$*=$1,s/ (-?)x(\PL+)/$1$2 $*/while s-x([*/])- -||s/x([+-])/ /;$_!e;y/x//d |
| A slight improvement... | |||
| 131.49 | Mykola Zubach | Tue Sep 3 13:18:26 2002 | -lp y/() \t/<>/d;for(s/(?<![>\d])(-?\d+)/<$1>/g;s/<(<[^>]+>)>/$1/||s@>([/*]|([+-]))<
([^<>]+)>(?(2)([^*/]|$))@ $3 $1>$4@;){}y/<>//d
|
| old version, but improved This only seems to remove whitespace. For example the first test: Input: 1 - - 2 Output: 1--2 | |||
| 131.74 | Eugene van der Pijll | Mon Sep 2 17:03:54 2002 | -lp s/\s//g;$n='((\B-)?\w+)';push@a,"$1 $4 $3"while s#\($n\)#$1#g||s#$n([*/])$n#a.@a#e||s#$n([-+])$n#a.@a#e;1while s#a(\d+)#$a[$1]# |
| Alas, alas, the program fails for (18*16*16*5-1+12+15+18*1-8+6/7-6-2-(19)*(17))+8+((9/14))*16+15*11*13/20*4+16- 7-19+9+(12)+(4)+20-1*(16)+(6)+19*13/1*6*5/17-17+(2)*6*4-19*17-4*(1-20*11*3*19 +3/(8+9*20/16+(16)/8/3))-((3))*(6+2-(17)*2*2-(10))*(14-15*4+6/1 | |||
| 134.71 | Mtv Europe | Sun Sep 1 22:00:48 2002 | -p /\(/?push@;,0:/\d/?push@o,$_:do{push@o,pop@;while/\*|\//?$;[-1]=~//:$;[-1];/\)/?pop@;:push@;,$_}for/(?<!\d|\))-?\d+|\S/g,a;$_="@o
"
|
| and yet another way how to kill the cat. fast.
Unfortunaly, it fails the test with '1 - -\t2' | |||
| 140.77 | Ton Hospel | Sun Sep 1 22:24:24 2002 | -pl s/./,"$&",sub{bless["\@_$&"]}/gfor$a="+-*/";s#(^\s*|[-+*/(]\s*)(-?\d+)#$1(bless["$2"])#g;s/^/use overload'""',sub{\$_[0][0]}$a;/;$_=eval |
| Unfortunaly, it fails the test with '1 - -\t2'. | |||
| 140.84 | Eugene van der Pijll | Tue Sep 3 17:26:15 2002 | -lpX sub a{bless\"@_"}use overload neg,sub{a('-'.shift)},'""',sub{${$_[0]}},nomethod,sub{a shift,shift,pop};s/-/ -/g;s/\d+/a("$&")/g;$_=eval |
| Finally, a working solution. I hope. fail's on input (-1 + 2), outputs nothing .. check if you submitted the right one, or made a paste error | |||
| 142.56 | Rick Klement | Sun Sep 1 20:34:13 2002 | -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/=/-/ |
| Fails on 1 - - | |||
| 144.67 | Alain "TopMach" Dupuis | Sat Sep 7 19:51:05 2002 | -lp s/\s//g;$%=/\(/,s!\(?([^()]+)\){$%}!$_=$1;for$o('*/','+-'){1while s#([^SO])([$o])(-?[S\d]+(O.|S\d+)*)#$1S$3O$2#}$_!ewhile/(\d|\W)\W/;y/SO/ / |
| Test 45 is taking ages in the machines of two referees. It seems this program does not satisfy the time constraint stated in the rules. | |||
| 155.49 | Mtv Europe | Sun Sep 1 17:06:19 2002 | -p s/\d+/\$$&/g;s/-/ -/g;close STDERR;$_=`$^X -MO=Deparse,-p -e '$_'`;
$q=qr/\(((??{$q})|-?\$\d+)( .)?( (??{$q})| -?\$\d+)?\)/;
1while s/$q/$1$3$2/;y/$;//d
|
| hmm, artistic or unortodox? at least it's platform dependant (needs s/'/#/g for windows). and speed is not my fault, it's Deparse's! :) too slow and platform dependant .. even arthistic / unorthodox need to pass the judge :) | |||
| 155.81 | TheodoreYoung | Tue Sep 3 17:59:34 2002 | -l sub n{bless\shift}use overload'""',sub{${$_[0]}},'neg',sub{n "-$_[0]"},'nomethod',sub{n "@_[0,1,3]"};$_=<STDIN>;s/(-?)[0\s]*(\d+)/ $1 n($2)/g;print eval |
| doesnt pass any tests .. | |||
| 159.73 | Amir Karger | Wed Sep 4 20:01:29 2002 | -pl @a=qw(+- */);sub e{my($l,$o)=@_;if($l-2){do{e($l+1);$o&&push@c,$o}while$o=s#^[$a[$l]]##&&$&}else{s/^\(//?e()+s/^\)//:s/-?\d+//+push@c,$&}}s/\s//g;e;s/$/@c/
|
| Squeeze out lots o' whitespace.
Sadly, I'm still very very far from the top. But it's a good enough score to at least enter the contest. never finish test1 | |||
| 179.70 | nashdj | Sun Sep 1 09:56:31 2002 | -l $e=qr/(??{$t})(([+-])(??{$t})(?{push@_,$2}))*/;$t=qr/(??{$f})(([*\/])(??{$f})(?{push@_,$2}))*/;$f=qr/\((??{$e})\)|((-|)\d+)(?{push@_,$1})/;$_=<>;s/ |\t//g;$_=~$e;$,=' ';print@_ |
| Consistently causes Perl 5.6.1 on Linux to segfault in test 33. | |||
| 182.29 | Qingning Huo | Tue Sep 3 07:57:22 2002 | -pl s#\s##g; s#(.*?)(^|[-+*/(])(-?\d+)#$1$2\n$3\n#g; 1while s#\((\n.+\n)\)#$1#|| s#^([^)]*?)(.+)\n([*/])\n(.+)#$1$2 $4 $3#|| s#(.+)\n([-+])\n(.+)(?=\n|$)(?!\n[*/])#$1 $3 $2#; s#\n##g |
| Way too slow. Test 45 (v7) has now taken 12 minutes of CPU time on the specified machine, and the really long tests are still to come. | |||
| 184.43 | TheodoreYoung | Tue Sep 3 13:14:47 2002 | -l package A;
$_=<STDIN>;
s/(-?)[0 ]*(\d+)/ $1 A->n($2)/g;
print eval;
use overload
'""'=>sub{${$_[0]}},
'neg'=>sub{n A "-$_[0]"},
'nomethod'=>sub{n A "@_[0,1,3]"};
sub n{bless \$_[1]} |
| This doesn't seem to produce any output besides a newline for any input. | |||
| 189.56 | Greg Allen | Sat Sep 7 17:09:47 2002 | -pl $*='(?:-?\d+(?: (?:[-*\/+]|-?\d+))*)';sub a{$_=~$1?$1:$`;0while s/\(([^()]+)\)/&a/e;s&($*(?:[*/]$*)*)([*/])($*)&a(" $3 $2")⪚$_=a(" $3 $2")if/()([-+])($*)$/;"$_@_";}s/\s//g+s/(.*)/a/e
|
| hurrah, some semblance of respectability Hangs on test1. | |||
| 190.43 | Qingning Huo | Fri Sep 6 08:20:58 2002 | -p y/ //d;my@o;{s/^(\(+)?(-?\d+)//;$_.=$1;push@o,$2;while(s/^\)//||/^
/){push@o,$&while
s#[^(
]$##;chop}if(s/^.//){$_.=$&;push@o,$&while
s#[^(
](?=[-+]$)##||s#[*/](?=[*/]$)##;redo}}$_="@o
" |
| Fails the first test: Input: 1 - - 2 Output: 1 - 2 - | |||
| 194.56 | Greg Allen | Sat Sep 7 17:23:32 2002 | -pl $*='(?:-?\d+(?: (?:[-*\/+]|-?\d+))*)';sub a{$_=$1;0while s/\(([^()]+)\)/&a/e;s&($*(?:[*/]$*)*)([*/])($*)&a(" $3 $2")⪚$_=a(" $3 $2")if/^(.*(?:\d| .))([-+])($*)$/;"$_@_";}s/\s//g+s/(.*)/a/e
|
| hurrah, some semblance of respectability Sorry, the segfault persists. The problematic piece of code is: s&($*(?:[*/]$*)*)([*/])($*)&a(" $3 $2")⪚ | |||
| 206.77 | Michael Thelen | Sun Sep 1 20:49:13 2002 | -ln s/\s//g;/\d/?push@g,$_:/\)/?($f=pop@s)ne'('&&push(@g,$f)&&redo:(/([+-])|[*\/]/&&($z="*/".($1&&"+-"),"@s"=~/[$z]$/)&&push(@g,pop@s)&&redo,push@s,$_)for/(?:(?<![\d()])-)?\d+|./g;push@g,reverse@s;print"@g" |
| Fails on (-1 + 2) | |||
| 208.53 | Greg Allen | Sat Sep 7 10:46:04 2002 | -pl $*='(?:-?\d+(?> (?:[^I*\/+]|-?\d+))*)';sub a{$_=$1;0while s/\(([^()]+)\)/&a/e;s&($t(?:[*/]$*)*)([*/])($*)&a(" $3 $2")⪚$_=a(" $3 $2")if/^(.*)([+^I])($*)/;"$_@_";}s/\s//g+s/(\d|\))-/$1^I/g+s/(.*)/a/e+y/^I/-/
|
| so much effort, so little progress Running test 47 ... Program rpn.pl killed by signal (11) consistently dies on test47 | |||
| 228.17 | Amir Karger | Wed Sep 4 19:59:55 2002 | -pl @a=qw(+- */);
sub e{
my ($l,$o) = @_;
if ($l-2) {
^Ido {
^I e($l+1);
^I $o && push @c,$o
^I} while $o = s#^[$a[$l]]## && $&
} else {
^Is/^\(// ? e() + s/^\)// : s/-?\d+// + push @c, $&
}
}
s/\s//g;
e;s/$/@c/
|
| Get rid of long variable names.
Realized that arith/mult. expressions are perfect for do while loops. doesnt finish fist test. | |||
| 229.49 | Mtv Europe | Thu Sep 5 18:33:18 2002 | -p use B;s/-/
-/g;s/\d+/\$$&/g;
for($x=($y=B::svref_2object(eval"sub{$_}"))->START,
@v=($y->PADLIST->ARRAY)[1]->ARRAY;$_=($x=$x->next)->name,!/ea/;){
push@a,/n/?-pop@a:/g/?@v[$x->padix]->NAME:/e/?'/':/y/?'*':/s/?'-':'+'
}$_="@a
"
|
| this B thing crashes too often Failed with this message : Can't locate object method "padix" via package "B::SVOP" (perhaps you forgot to load "B::SVOP"?) | |||
| 234.76 | Michael Thelen | Sun Sep 1 20:11:39 2002 | -ln s/\s//g;/\d/?push@g,$_:/\)/?($f=pop@s)ne'('&&push(@g,$f)&&redo:(/[+-]/?"@s"=~/[\*\/+-]$/&&(push(@g,pop@s),redo):/[*\/]/&&"@s"=~/[\*\/]$/&&(push(@g,pop@s),redo),push@s,$_)for/(?:(?<![\d()])-)?\d+|[(-\/]/g;push@g,reverse@s;print"@g" |
| Better, but still a long way to go. Fails on (-1 + 2) | |||
| 263.69 | Greg Allen | Thu Sep 5 10:38:22 2002 | -pl sub t{$_=pop;s/\((.*)\)/a($1)/e;"$_@_"}$b=qr/\((?:(?>[^()]+)|(??{$b}))*\)/;$p=qr/$b|-?\d+/;sub p{$_=shift;/(\*|\/)($p)$/?p("$`",'',t(" $1@_",$2)):t@_,$_}sub a{$_=shift;/$p([-+]($p(?:[*\/]$p)*))+$/&&/(.)(\Q$+\E)$/?a("$`",'',p($2," $1@_")):p$_,@_}y/ ^I//d;$_=a$_
|
| guess this approach won't get too close to 104 then... Segfaults on 5.6.1 on Linux. Probably the (??{}). | |||
| 337.49 | Constantin M | Fri Sep 6 21:34:42 2002 | $s='-+*\/'; $d='-?\d+'; $_=<>; s/\s+//g; @_=(m/(^$d|(?[$s(] </td></tr><tr><td colspan="2"> Paste your solution in the textarea above or upload it here: <input type="file" name="file"> <span class="error">Please use specified shebang</span> <br><br> </td></tr><tr><td> Comment: </td><td> <textarea cols="40" rows="4" name="comment"> |
| seem to have happened something strange when you submitted because your solution have a lot of html in it .. | |||
| 365.30 | Philippe Bricout | Sat Sep 7 19:08:28 2002 | -pl y#*/+-#a-d#;
s/\s*([a-d]|[()])\s*/_$1_/g;
s/(^|[a-d(])_*d_*(\d+)/$1_d$2/g;
y/ _/ /s;
&p while &d;
y#_a-d# */+-#s;
s/^\s|\s$//g;
sub a{&p while s/\( (\w+) \)/$1/}
sub b{&p while &a;s/\( (\w+) ([a-d]) (\w+) \)/$1_$3_$2/}
sub c{&p while &b;s/(\w+) ([ab]) (\w+)/$1_$3_$2/}
sub d{&p while &c;s/(\w+) ([cd]) (\w+)/$1_$3_$2/}
sub p{#y#a-d#*/+-#;print;y#*/+-#a-d#;
1}; |
| This time the question is 42, not the answer! Don't know why test 42 failed : problem with my script or problem during evaluation of division and big interger ?
Help me ! :) As you already say, it fails on test 42. We are sorry we cannot help participants, if referees did it the game would be spoiled. | |||
| 422.98 | Taipei.pm | Sun Sep 1 13:38:11 2002 | -wle 'print %]'; print '$_/%&__$%%[s/%$@$#//\^#####################################################################################################################################################################################################################################################################################################################################################################################'; |
| 818.00 | Ton Hospel | Sun Sep 1 13:42:20 2002 | #!perl -wle 'print $_$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ |