Topological Sort
Score: 74.50 (pass)
Finally, I can get rid of the "die" at the end. I had another way with "exec$_" which I found quite devious, but 1/!$_ is one stroke shorter so there it is.
#!perl -ln0
s/^(.+) \1$/$1/m|/ \Q$&
/||print($&)^s/^\Q$&\E\s//gmwhile/\S+/g;1/!$_
|
Score: 76.49 (pass)
Never in my wildest dreams would I have thought that you could write something like s///gmwhile with no whitespace.
#!perl -ln0
s/^(.+) \1$/$1/m|/ \Q$&
/||print($&)^s/^\Q$&\E\s//gmwhile/\S+/g;??&&die
|
Score: 77.49 (pass)
AT LAST I can get rid of one of those damn \Q...\E characters!!!
#!perl -ln0
s/^(.+) \1$/$1/m|/ \Q$&
/||print($&)^s/^\Q$&\E\s//gm while/\S+/g;$_&&die
|
Score: 79.49 (pass)
#!perl -ln0
s/^(.+) \1$/$1/m|/ \Q$&\E
/||print($&)^s/^\Q$&\E\s//gm while/\S+/g;$_&&die
|
Score: 80.48 (fail)
Hum, this one is a little shaky, I'm not sure it will pass all the tests... Anyway, I got a solution with 81 strokes if this one is not correct.
#!perl -ln0
s/\b(.+) \1/$1/|/ \Q$&\E$/m||print($&)^s/^\Q$&\E\s//gm while/\S+/gm;$_&&die
|
Score: 80.49 (pass)
OK this one should work. There is one test case missing from the test program, something like:
a aa
c aa
b aa
#!perl -ln0
s/^(.+) \1$/$1/m|/ \Q$&\E$/m||print($&)^s/^\Q$&\E\s//gm while/\S+/g;$_&&die
|
Score: 82.49 (pass)
It's always when you post a solution that you find how to improve it
#!perl -ln0
s/^(.+) \1$/$1/gm;/ \Q$&\E$/m||print($&)^s/^\Q$&\E\s//gm while/\S+/gm;$_&&die
|
Score: 83.49 (pass)
I used one of Ton's trick to gain a stroke!
#!perl -ln0
s/^(.+) \1$/$1/gm;/ \Q$&\E$/m||print($&)^s/^\Q$&\E\s//gm while/^\S+/gm;$_&&die
|
Score: 84.47 (pass)
Whew, I'm having more and more trouble understanding what my solution does...
#!perl -ln0
s/^(.+) \1$/$1/gm;/ \Q$&\E$/m||print$&and s/^\Q$&\E\s//gm while/^\S+/gm;$_&&die
|
Score: 91.54 (fail)
Woohoo! Under 100! And there is still room for improvement...
#!perl -0777n
s/^(.+) \1$/$1/gm;while(/^\S+/gm){if(!/ $&$/m){print"$&\n";s/^$&[ \n]//gm}}/\S/&&die
|
Score: 97.55 (pass)
Oops, this one should work better... Still under 100!
#!perl -0777n
s/^(.+) \1$/$1/gm;while(/^\S+/gm){if(!/ \Q$&\E$/m){print"$&
";s/^\Q$&\E[
]//gm}}/\S/&&die
|
Score: 126.48 (pass)
Again, by a hair!
#!perl -ln
/ /;++$b{$'}{$`}if$`ne$';$b{$`}||={}}{map delete@{%$_}{@d},values%b while delete@b{@d=grep!%{$b{$_}}&&print,keys%b};exit%b
|
Score: 131.50 (pass)
By a hair...
#!perl -ln
/ /;++$b{$'}{$`}if$`ne$';$b{$`}||={}}{while(delete@b{@d=grep{!%{$b{$_}}&&print}keys%b}){delete@{%{$b{$_}}}{@d}for keys%b}exit%b
|
Score: 133.51 (pass)
Must... write... thesis...
Must... not... play... golf...
argl
#!perl -ln
/ /;++$b{$'}{$`}if$`ne$';$b{$`}||={}}{while(%b){delete@b{@d=grep{!%{$b{$_}}&&print}keys%b}||die;delete@{%{$b{$_}}}{@d}for keys%b}
|