#!perl -p y/ //d;s/\b\D/x$&/g;s--$_=$1;s// $2 $1/while/x(.)(\PL+)/+/x([*\/])(\PL+)/;$_-ewhile/(.+)x/+/\(([^()]+)\)/ |
#!perl -p y/ //d;s/\b/x/g;s~~$_=$1;s/x([$1])(-?)x(\PL+)/ $2$3 $1/while/x(\D)/|/x([*\/])/;$_~ewhile/x(.+)x/|/\(([^()]+)\)/ |
#!perl -p y/ //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 |
#!perl -p y/ //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 |
#!perl -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// |
#!perl -p $_="($_)";y/ //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 |
A slight improvement...
#!perl -p $_="($_)";y/ //d;s/\b/x/g;1while s!\(([^()]+)\)!$_=$1;$*=$1,s/ (-?)x(\PL+)/$1$2 $*/while s-x([*/])- -||s/x([+-])/ /;$_!e;y/x//d |
Sorry, I sent a wrong version, this one works!
#!perl -p $_="($_)";y/ //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 |
#!perl -p $_="($_)";y/ //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 |
#!perl -p $_="($_)";y/ //d;s/\b/x/g;1while s!\(([^()]+)\)!$_=$1;$_="$` $2$3 $1$'"while/x([*\/])(-?)x(\PL+)/||/x(\D)(-?)x(\PL+)/;$_!e;y/x//d |
The tiebreaker for this hole is quite fun...
makes the pm easier to read :)
#!perl -p $_="($_)";y/ //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 |
Thanks to mtve for the \PL trick!
#!perl -p $_="($_)";y/ //d;s/(? |