Infix to RPN
Score: 133.62 (pass)
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.
#!perl -p
s/\s//g;map{$0=m+[*/]+?'*/':'^(';$0[@0]=pop@1until/\(|\d/|"@1"!~/[$0]$/;/\)/?pop@1:push@{1-/\w/},$_}/(?
|
Score: 138.63 (pass)
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! :-)
#!perl -p
s/\s//g;map{if(!/\(|\d/){$0=m+[*/]+?'*/':'^(';$0[@0]=pop@1while"@1"=~/[$0]$/}/\)/?pop@1:push@{1-/\w/},$_}/(?
|
Score: 138.64 (pass)
Changing back to push() made it a lot faster
#!perl -p
s/\s//g;map{if(!/\(|\d/){$0=m+[*/]+?'*/':'^(';push@0,pop@1while"@1"=~/[$0]$/}/\)/?pop@1:push@{1-/\w/},$_}/(?
|
Score: 140.63 (pass)
#!perl -p
s/\s//g;map{if(!/[(\d]$/){$0=m+[*/]+?'*/':'^(';@0=(@0,pop@1)while"@1"=~/[$0]$/}/\)/?pop@1:push@{1-/\w/},$_}/(?
|
Score: 147.65 (pass)
#!perl -p
s/\s//g;map{if(/[^(\d]$/){$0=/[)+-]/?'^(':'*/';@0=(@0,pop@1)while"@1"=~/[$0]$/}/\)/?pop@1:push@{1-/\w/},$_}"($_)"=~/(?
|
Score: 154.67 (pass)
#!perl -p
s/\s//g;for("($_)"=~/(?
|
Score: 156.68 (pass)
#!perl -p
s/\s//g;$_="($_)";for(/(?
|
Score: 165.75 (pass)
#!perl -p
s/\s//g;$_="($_)";for(/(?
|
Score: 190.76 (pass)
Still on the wrong path, but submitting this to at least pass Qingning Huo.
#!perl -p
s/\s//g;$_="($_)";for(/(?
|
Score: 195.75 (pass)
#!perl -p
s/\s//g;$_="($_)";for(/(?
|
Score: 200.77 (pass)
Bleah! Still disgusting.
#!perl -p
s/\s//g;for(/(?
|
Score: 290.48 (pass)
Submitting my first working solution, for the record. Haven't shortened it at all yet, obviously.
#!perl
$_=<>;s/\s//g;@s=/(?
|