Topological Sort
Score: 117.57 (pass)
I am sooooo close to a break-through new algorithm. What do you mean, there's only half an hour left? I wonder if `/ has a stroke or two in reserve.
#!perl -aln
/ /,@n{@F}+=$`ne$'&!$p{$_}++}{0-$n{$x=$_}or$z+=print,map{/ /,$n{$'}-=$`eq$x}%p,"$x $x"for(@m=keys%n)x@m;$z-@m&&&
|
Score: 118.57 (pass)
Caught `/ at last! Will he respond though?
#!perl -aln
/ /,@n{@F}+=$`ne$'&!$p{$_}++}{
0-$n{$x=$_}or$z+=print,map{/ /,$n{$'}-=$`eq$x}%p,"$x $x"for(@m=keys%n)x@m;$z-@m&&&
|
Score: 121.56 (pass)
Still fighting! Puff! Puff! I've got to get into shape for these vigorous sprints to the finish line. Hope `/ is worried.
#!perl -aln
@n{@F}+=!s/^(.+) \1$//&!$p{$_}++}{0-$n{$x=$_}or$z+=print,map{/ /,$n{$'}-=$`eq$x}%p,"$x $x"for(@m=keys%n)x@m;$z-@m&&&
|
Score: 123.57 (pass)
This is a really ugly solution. I hope, however, it makes `/ just a wee bit scared. :-)
#!perl -aln
@n{@F}+=!s/^(.+) \1$//&!$:{$_}++}{0-$n{$x=$_}or++$z,print,map/ /&$`eq$x&&--$n{$'},%:,"$x $x"for(@m=keys%n)x@m;$z-@m&&&
|
Score: 128.53 (pass)
Alas, still on the same horse. I've tried a couple of different approaches, but could not make them shorter. :-( Still, as is often the case, trying a different approach often yields a tactical trick that can then be applied to a previous solution.
#!perl -aln
@n{@F}+=!s/^(.+) \1$//&!$:{$_}++}{@l=grep!$n{$_},@m=keys%n;//,print,push@l,grep!--$n{$_},map/^\Q$'\E (.+)/,%:for@l;@l-@m&&&
|
Score: 128.59 (fail)
Finally, I understand what this hard-wired 200 limit business is about! This solution is quite disgusting but I am curious to know if the referees accept such a solution or not.
#!perl -aln
@n{@F}+=!s/^(.+) \1$//&!$:{$_}++}{0-$n{$x=$_}or++$z,print,map/^\Q$x\E (.+)/&&--$n{$1},%:,"$x $x"for(@a=keys%n)x200;$z-@a&&&
|
Score: 130.48 (pass)
Don't laugh! Not only does it have a better tie-breaker, it is faster too!
#!perl -aln
/ /;$p{$_}++or@n{@F}+=$`ne$'&&!!push@{$s{$`}},$'}{@l=grep!$n{$_},@m=keys%n;print,push@l,grep!--$n{$_},@{$s{$_}}for@l;@l-@m&&&
|
Score: 130.53 (pass)
#!perl -aln
@n{@F}+=!s/^(.+) \1$//&!$:{$_}++}{@l=grep!$n{$_},@m=keys%n;/.+/,print,push@l,grep!--$n{$_},map/^\Q$&\E (.+)/,%:for@l;@l-@m&&&
|
Score: 131.52 (fail)
What an interesting game! Much of the golfing elite (such as Eugene,
Stephen and Mtv) seem to be stuck in the mud, while a few insightful
beginners and lesser known golfers have broken through to the
80s and below.
I suspect I am using a similar approach to those in the 120's
and 130's and that Stephen and Eugene, being brilliant golfers,
have golfed this well-known and straightforward approach down
to a limit of 124.56.
No, to get to 80 will require a change of horse.
So, instead of wasting more time golfing this approach, I should
go the stream, grab a fresh, wet trout and slap myself about the
face with it.
#!perl -aln
@n{@F}+=!s/^(.+) \1$//&!$:{$_}++}{@l=grep!$n{$_},@m=keys%n;$x=$_,print,push@l,grep!--$n{$_},map/^\Q$x\E (.+)/,%:for@l;@l-@m&&&
|
Score: 132.50 (fail)
Using the call to undefined subroutine ';' (sic) to save 2 strokes over die. For golf historians, this trick was made infamous by Piers Cawley in the inaugural Santa Claus tournament. Gee, `/ is playing well, he might even overtake the great Eugene van der Pijll and Stephen Turner! I can't catch him. :-(
#!perl -aln
@n{@F}+=!s/^(.+) \1$//&!$:{$_}++}{@l=grep!$n{$_},keys%n;$x=$_,print,push@l,grep!--$n{$_},map/^\Q$x\E (.+)/,%:for@l;@l-keys%n&&&
|
Score: 137.46 (pass)
caught `/ again!
#!perl -aln
$p{$_}++or@n{($:,$;)=@F}+=$:ne$;&&!!push@{$s{$:}},$;}{@l=grep!$n{$_},keys%n;print,push@l,grep!--$n{$_},@{$s{$_}}for@l;@l-keys%n&&die
|
Score: 142.46 (pass)
#!perl -aln
$p{$_}++or@n{($:,$;)=@F}+=$:ne$;&&(push(@{$s{$:}},$;),1)}{
@l=grep!$n{$_},keys%n;print,push@l,grep!--$n{$_},@{$s{$_}}for@l;@l-keys%n&&die
|
Score: 143.46 (pass)
This is utter bilge and I have no idea why it works but I've finally caught `/ by a nostril. :)))
#!perl -aln
$p{$_}++or@n{($:,$y)=@F}+=$:ne$y&&(push(@{$s{$:}},$y),1)}{
@l=grep!$n{$_},keys%n;print,push@l,grep!--$n{$_},@{$s{$_}}for@l;
@l-keys%n&&die
|
Score: 154.48 (pass)
Using exit like this may be unsound; I will leave it for referees to decide. Note that exit(256) returns 0 to the operating system.
#!perl -aln
$p{$_}++or($:,$;)=@F,$n{$:}+=0,$:eq$;or++$n{$;},push@{$s{$:}},$;}{
@l=grep!$n{$_},keys%n;print,map--$n{$_}||push(@l,$_),@{$s{$_}}for@l;
exit@l-keys%n
|
Score: 155.48 (pass)
Shuffling deck chairs on the Titanic. And yet I am enjoying it in a perverse kind of way.
#!perl -aln
$p{$_}++or($:,$;)=@F,$n{$:}+=0,$:eq$;or++$n{$;},push@{$s{$:}},$;}{
@l=grep!$n{$_},keys%n;print,map--$n{$_}||push(@l,$_),@{$s{$_}}for@l;
@l-keys%n&&die
|
Score: 169.47 (pass)
Don't you dare laugh! Just because all I did was golf on PPT tsort.pl a bit. Oh well, it's a start. But I fear I won't have the time to hold off `/ this time and will wind up being stabbed in the back while changing a light bulb.
#!perl -aln
$p{$_}++or($:,$;)=@F,$n{$:}+=0,$:eq$;or++$n{$;},push@{$s{$:}},$;}{
@l=grep!$n{$_},keys%n;while(@l){--$n{$_}||push@l,$_ for@{$s{$_=pop@l}};print}
map$_&&die,values%n
|