Topological Sort Post Mortem Back to Perl Golf

Accepted | Artistic/Unorthodox | Rejected

Referee comments are in italics. Blue rows denote golfer's best solution. Red text denotes special characters.

Accepted

ScoreGolferSubmit TimeCode
64.58 Ton Hospel Sat Jul 6 22:05:39 2002
-ln0 / \Q$&/||print$1while s/(
|(?= ?\G))\Q$&/ 
/g,/(\S+) /g/$#+
64.58 Ton Hospel Sun Jul 7 11:46:18 2002
-ln0 /(?<= )\Q$&
/||print$1while s/(
|\G)\Q$&/ 
/g,/(\S+) /g/$#+
the dual solution
65.50 Ton Hospel Wed Jul 3 16:46:46 2002
-ln0 / \Q$&\E$/m||print$&while s/(^|\G)\Q$&\E\s/
/mg,/(\S+)/g/$#+
Do everything with one statement A pity I needed to add that () But maybe distinguishing $1 and $& will prove useful
65.50 Ton Hospel Wed Jul 3 12:05:33 2002
-ln0 / \Q$&\E$/m||print$&while s/(^|\G)\Q$&\E\s/
/mg,/\S+/g;1/!//
68.52 Mtv Europe Sun Jul 7 15:37:14 2002
-ln0 / \Q$&
/||print$&while s/^\Q$&\E\s|^(.+) \1$/$1/mg,/\S+/g;a%!??
another two bytes, improved tie and a little obfu at the end :) perhaps my last, thanks to referees and to all.
70.48 Ton Hospel Tue Jul 2 14:29:42 2002
-ln0 s/\G \Q$&
/
/+/ \Q$&
/||print$&while s/^\Q$&\E\s//mg,/\S+/g;1/!//
70.63 Mtv Europe Sat Jul 6 18:56:10 2002
-p0 $\.="$&
"x!/ \Q$&
/,s/^\Q$&\E[
 ]|^(.+) \1$/$1/mgwhile/\S+/g;a/!//
strangely it runs so long so i began to wonder will it be accepted?
71.49 Ton Hospel Tue Jul 2 13:12:08 2002
-ln0 s/\G \Q$&
/
/-/ \Q$&
/||print($&)+s/^\Q$&\E\s//mgwhile/\S+/g;1/!//
71.51 Ton Hospel Tue Jul 2 13:26:12 2002
-p0 s/\G \Q$&
/
/+/ \Q$&
/ or$\.="$&
",s/^\Q$&\E\s//mgwhile/\S+/g;1/!//
72.49 Ton Hospel Tue Jul 2 12:49:11 2002
-ln0 s/\G \Q$&
/
/+/ \Q$&
/||print($&)+s/^\Q$&\E\s/
/mgwhile/\S+/g;1/!//
73.46 Albert Dvornik Fri Jul 5 22:27:31 2002
-ln0 s/\G \Q$&
/
/./ \Q$&
/||s/^(\Q$&\E)\s//gm-print$1while/\S+/g;lc&&die
Got rid of $q; two characters are better than nothing...
73.49 Ton Hospel Tue Jul 2 12:40:32 2002
-ln0 s/\G \Q$&
/
/+/ \Q$&
/||print($&)+s/^\Q$&\E\s/\n/mgwhile/\S+/g;1/!//
74.47 Wladimir Palant Sun Jul 7 16:51:26 2002
-ln0 $a="\Q$&",s/\G $a$//m|/ $a$/m||(print$&)&s/^$a\s//gmwhile/\S+/g;a%!$_
Improving the result by 0.01, have no better idea
74.48 Wladimir Palant Fri Jul 5 22:18:43 2002
-ln0 $a="\Q$&",s/\G $a$//m|/ $a$/m||print($&)&s/^$a\s//gmwhile/\S+/g;1%!$_
74.50 pom Sat Jul 6 22:00:14 2002
-ln0 s/^(.+) \1$/$1/m|/ \Q$&
/||print($&)^s/^\Q$&\E\s//gmwhile/\S+/g;1/!$_
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.
74.54 Ton Hospel Tue Jul 2 00:41:12 2002
-ln0 /^(.+) (?!\1
)\Q$&
/m||print($&)+s/^(\Q$&\E\s)+/
/mgwhile/\S+/g;1/!//
75.46 Albert Dvornik Fri Jul 5 01:19:06 2002
-ln0 $q="\Q$&",s/\G $q$//m,/ $q
/||s/^($q)\s//mg+print$1while/\S+/g;lc&&die
Handling only one "node node" at a time is enough.
75.50 Ala Qumsieh Mon Jul 8 04:50:52 2002
-ln0 s/^(.*) \1$/$1/mg;/ \Q$&
/||print($&),s/^\Q$&\E\s//mgwhile/\S+/g;$_&&&
Those brackets arount the print are killing me!
76.47 Wladimir Palant Fri Jul 5 14:27:39 2002
-ln0 $a="\Q$&",s/\G $a$//m|/ $a$/m||print($&)&s/^$a\s//gmwhile/\S+/g;$_&&die
76.49 pom Thu Jul 4 15:34:33 2002
-ln0 s/^(.+) \1$/$1/m|/ \Q$&
/||print($&)^s/^\Q$&\E\s//gmwhile/\S+/g;??&&die
Never in my wildest dreams would I have thought that you could write something like s///gmwhile with no whitespace.
76.50 Ala Qumsieh Mon Jul 8 03:51:25 2002
-ln0 s/^(.+) \1$/$1/gm;/ \Q$&
/||print($&),s/^\Q$&\E\s//mgwhile/\S+/g;$_&&&;
76.52 Qingning Huo Thu Jul 4 14:52:05 2002
-ln0 $*=qr/\Q$&/,s/^($*) $*
//,/ $*
/||s/^($*)\s//g&print$1while/\S+/g;a/!$_
76.54 Ton Hospel Mon Jul 1 23:20:05 2002
-ln0 /^(?!\Q$&\E ).* \Q$&
/m||print($&)+s/^(\Q$&\E\s)+/
/mgwhile/\S+/g;1/!//
76.58 Mtv Europe Sat Jul 6 13:28:37 2002
-p0 s/^(.+) \1$/$1/mg;$\.="$&
"x!/ \Q$&
/,s/^\Q$&\E[ 
]//mgwhile/\S+/g;a/!//
hmm, still works, strange.
77.46 Wladimir Palant Fri Jul 5 14:13:25 2002
-ln0 $a="\Q$&",s/\G $a$//m|/ $a$/m||print$&x1,!s/^$a\s//gmwhile/\S+/g;$_&&die
77.49 Ala Qumsieh Sun Jul 7 04:48:23 2002
-ln0 s/^(.+) \1$/$1/mg;/ \Q$&
/||print($&),s/^\Q$&\E\s//mgwhile/\S+/g;$_&&die
77.49 pom Wed Jul 3 16:27:21 2002
-ln0 s/^(.+) \1$/$1/m|/ \Q$&
/||print($&)^s/^\Q$&\E\s//gm while/\S+/g;$_&&die
AT LAST I can get rid of one of those damn \Q...\E characters!!!
77.52 Qingning Huo Wed Jul 3 17:50:52 2002
-ln0 $*=qr/\Q$&/,s/^($*) $*
//,/ $*$/||s/^($*)\s//g&print$1while/^\S+/g;a/!$_
77.52 Qingning Huo Wed Jul 3 21:23:16 2002
-ln0 $*=qr/\Q$&/,s/^($*) $*
//,/ $*
/||s/^($*)\s//g&print$1while/^\S+/g;a/!$_
improved tie-breaker
77.54 Mtv Europe Sat Jul 6 13:10:15 2002
-ln0 s/^(.+) \1$/$1/mg;/ \Q$&
/||print($&)+s/^\Q$&\E[ 
]//mgwhile/\S+/g;a/!//
just found new a/// operator
78.47 Wladimir Palant Fri Jul 5 13:25:16 2002
-0n $a="\Q$&",s/\G $a$//m|/ $a$/m||print"$&\n",!s/^$a\s//gmwhile/\S+/g;$_&&die
78.53 Ton Hospel Mon Jul 1 18:21:23 2002
-ln0 /^(?!\Q$&\E ).* \Q$&
/m||print($&)+s/^(\Q$&\E\s)+/
/mgwhile/^\S+/gm;1/!//
78.53 Juuso Salonen Sun Jul 7 20:43:35 2002
-ln0 S//\S+/g,/(?<!(^|\A)\Q$&\E) \Q$&
/m||print($&)+s/^(\Q$&\E\s)+//mgwhile/./
79.46 Albert Dvornik Thu Jul 4 19:52:49 2002
-ln0 $q="\Q$&",s/^$q $q$/$q/mg,/ $q
/||s/^($q)\s//mg+print$1while/\S+/g;lc&&die
79.49 Ala Qumsieh Thu Jul 4 15:06:43 2002
-ln0 s/^(.+) \1$/$1/mg;/ \Q$&
/||print($&),s/^\Q$&\E\s//gmwhile/^\S+/mg;$_&&die
79.49 pom Wed Jul 3 14:21:22 2002
-ln0 s/^(.+) \1$/$1/m|/ \Q$&\E
/||print($&)^s/^\Q$&\E\s//gm while/\S+/g;$_&&die
79.51 Qingning Huo Wed Jul 3 13:48:24 2002
-ln0 $*=qr/\Q$&/,s/^($*) $*
//,/ $*$/||s/^($*)\s//g&print$1while/^\S+/g;$_&&die
$* is fun.
79.53 Mtv Europe Sat Jul 6 00:36:38 2002
-ln0 s/^(.+) \1$/$1/mg;/ \Q$&
/||print($&)+s/^\Q$&\E[ 
]//mgwhile/\S+/g;//&&die
sleep
80.49 pom Wed Jul 3 08:26:53 2002
-ln0 s/^(.+) \1$/$1/m|/ \Q$&\E$/m||print($&)^s/^\Q$&\E\s//gm while/\S+/g;$_&&die
OK this one should work. There is one test case missing from the test program, something like: a aa c aa b aa
80.51 Ton Hospel Mon Jul 1 18:01:02 2002
-Xln0 /^(?!\Q$&\E ).* \Q$&
/m||print($&)+s/^(\Q$&\E\s)+/
/mgwhile/^\S+/gm;exit//
80.52 Juuso Salonen Thu Jul 4 18:42:28 2002
-ln0 s//
/;S//(\S+)/g,/(?<!
\Q$1\E) \Q$1
/||(print$1)&s/
(\Q$1\E\s)+/
/gwhile/./
81.49 Ala Qumsieh Thu Jul 4 04:56:19 2002
-ln0 s/^(.*) \1$/$1/mg;
/ \Q$&
/||print($&),s/^\Q$&\E\s//gmwhile/^\S+/mg;
$_&&die
Sorry for keeping you busy :)
81.51 Ton Hospel Mon Jul 1 16:39:51 2002
-Xln0 /^(?!\Q$&\E ).* \Q$&
/m||print"$&",!s/^(\Q$&\E\s)+/
/mgwhile/^\S+/gm;exit//
82.49 pom Tue Jul 2 16:56:47 2002
-ln0 s/^(.+) \1$/$1/gm;/ \Q$&\E$/m||print($&)^s/^\Q$&\E\s//gm while/\S+/gm;$_&&die
It's always when you post a solution that you find how to improve it
82.53 Mtv Europe Fri Jul 5 22:09:14 2002
-lan0 s/^(\S+) \1$/$1/mg;/ \Q$&
/||print($&)+s/^\Q$&\E[ 
]//mgwhile/\S+/g;/./&&die
just a surplus space
83.37 Keith Calvert Ivey Sun Jul 7 23:06:00 2002
-ln0 s/^(.+) \1$/$1/gm;print(($s)=grep$s!~/ \Q$_
/,split)/s/^\Q$s\E\s//gmwhile$s=$_
Finally, a breakthrough -- though I fear I'm still stuck in a local minimum
83.47 Qingning Huo Wed Jul 3 04:43:50 2002
-ln0 $r=qr/\Q$&/,s/^($r) $r
//m,/ $r$/m||s/^($r)\s//gm&print$1while/^\S+/gm;$_&&die
83.49 pom Tue Jul 2 16:42:25 2002
-ln0 s/^(.+) \1$/$1/gm;/ \Q$&\E$/m||print($&)^s/^\Q$&\E\s//gm while/^\S+/gm;$_&&die
I used one of Ton's trick to gain a stroke!
83.49 Wladimir Palant Fri Jul 5 10:19:53 2002
-0 $_=<>;$a="\Q$&",s/\G $a$//m|/ $a$/m||print"$&\n",!s/^$a\s//gmwhile/\S+/g;$_&&die
83.49 Albert Dvornik Thu Jul 4 18:30:13 2002
-ln0 s/^(.*) \1$/$1/mg;$q="\Q$&",/ $q$/m||s/^($q)\s//mg&&print$1while/\S+/g;$_&&die
Using //g is more compact than split.
83.50 Stephen Turner Sun Jul 7 17:00:03 2002
-lan0 for$a((@F)x@F){/^(?!\Q$a\E ).* \Q$a
/m||s/(?<!\S)\Q$a\E\s//g&&print$a}$_&&die
Whoops, nearly missed a simple four-stroke improvement.
83.53 Mtv Europe Fri Jul 5 22:01:12 2002
-lan0 s/^(\S+) \1$/$1/mg;/ \Q$&
/||print($&)+s/^\Q$&\E[ 
]//mg while/\S+/g;/./&&die
using ton-'s favourite technique - throwing away unnecessary chars
84.46 Michael Thelen Thu Jul 4 05:17:15 2002
-ln0 s/^(.*) \1$/$1/mg;s!.!/ \Q$&
/||(print$&)&s/^\Q$&\E\s//mg&redo while/\S+/g;&a!e
My program fits on one line! Well, besides the #!perl line, anyway.
84.47 pom Tue Jul 2 16:33:41 2002
-ln0 s/^(.+) \1$/$1/gm;/ \Q$&\E$/m||print$&and s/^\Q$&\E\s//gm while/^\S+/gm;$_&&die
Whew, I'm having more and more trouble understanding what my solution does...
84.50 Marko Nippula Fri Jul 5 11:54:37 2002
-lna0 for$a((@F)x@F){$z="\Q$a",/^(?!$z ).* $z
/m||s/(\G|\s)$z\s/
/g&&print$a}&#if/./
85.48 Qingning Huo Tue Jul 2 13:02:14 2002
-ln0 $r=qr/\Q$&/,s/^($r) \1$/$1/m,/ $r$/m||s/^($r)\s//gm&print$1while/^\S+/gm;$_&&die
85.49 Wladimir Palant Fri Jul 5 09:55:42 2002
-0 $_=<>;s/\G \Q$&\E$//m|/ \Q$&\E$/m||print"$&\n",!s/^\Q$&\E\s//gmwhile/\S+/g;$_&&die
85.51 Michael Thelen Thu Jul 4 04:51:52 2002
-ln0 s/^(.*) \1$/$1/mg;/./&&${/ \Q$&
/||(print$&)&s/^\Q$&\E\s//mg&redo while/\S+/g}/0
Finally got rid of that dang $t, and now the program almost fits on one line. I can feel more strokes here to be shaved.
86.47 Ala Qumsieh Thu Jul 4 04:52:37 2002
-ln0 s/^(.*) \1$/$1/mg;
/^.* \Q$&
/ms||print($&),s/^\Q$&\E\s//gmwhile/^\S+/mg;
$_&&die
86.50 Michael Thelen Wed Jul 3 23:57:19 2002
-ln0 s/^(.*) \1$/$1/mg;/ \Q$&
/||($t=print$&)&s/^\Q$&\E\s//mgwhile/\S+/g;///$t--&&redo
Continuing the variation on a theme. I have a feeling this may be my last improvement for a while...
86.54 Juho Snellman Sun Jul 7 23:32:23 2002
-ln0 $_ x=3;s/(^| )(\Q$1\E\s)+/$1&&&1/megwhile/
(\S+)\s(?!\C*
(?!\1 ).+ \1
)/&&print$1
Replaced x=2 with x=3, which allowed changing a ^ from the regexp to \n, which allowed removing a /m-modifier from the regexp.
87.51 Stephen Turner Sun Jul 7 15:18:24 2002
-lan0 for$a((@F)x y/
//){/^(?!\Q$a\E ).* \Q$a
/m||s/(?<!\S)\Q$a\E\s//g&&print$a}$_&&die
Uglier, but better tie-breaker.
87.53 Stephen Turner Sun Jul 7 15:18:04 2002
-lan0 for$a((@F)x y/
//){$b="\Q$a";/^(?!$b ).* $b
/m||s/(?<!\S)$b\s//g&&print$a}$_&&die
Into the 80's. Now if I can only lose another 23 strokes in the next 13 hours, I could still win this!
87.54 Juho Snellman Thu Jul 4 22:20:04 2002
-ln0 $_ x=2;s/(^| )(\Q$1\E\s)+/$1&&&1/megwhile/^(\S+)\s(?!\C*^(?!\1 ).+ \1
)/m&&print$1
Finally had time to construct a test-case for the suspicious bit of code in my solution. Any sub-84 solution from me is going to fail on "a b b c a a". Time for v1.9? :-)
87.57 Eugene van der Pijll Mon Jul 8 02:12:30 2002
-lan0 sub f{$p{$_}||=1/!$g{$_}+++map(&f,$x=~/^(.*) (?!\1
)\Q$_
/mg)+print}$x=$_;f for@F
88.47 Ala Qumsieh Thu Jul 4 04:45:36 2002
-ln0 s/^(.*) \1$/$1/mg;
/^.* \Q$&\E
/ms||print($&),s/^\Q$&\E\s//gmwhile/^\S+/mg;
$_&&die
inching closer .. and closer ..
88.50 Michael Thelen Wed Jul 3 23:53:39 2002
-ln0 s/^(.*) \1$/$1/mg;/ \Q$&
/||($t=print$&)&s/^\Q$&\E\s//mgwhile/\S+/g;1/$t--,//&&redo
Okay, now we'll do illegal division by zero. How many ways can we get perl to die? ;-)
88.51 Wladimir Palant Fri Jul 5 01:36:36 2002
-0 $_=<>;s/^(\S+) \1$/$1/gm;/ \Q$&\E$/m||print"$&\n",!s/^\Q$&\E\s//gmwhile/\S+/g;$_&&die
88.52 Mtv Europe Fri Jul 5 20:55:40 2002
-lan0 s/^(\S+) \1$/$1/mg;/ \Q$&
/||print($&)+s/^\Q$&\E[ 
]//mg+redo while/\S+/g;/./&&die
small step
89.50 Qingning Huo Tue Jul 2 11:43:23 2002
-ln0 $0=$&,s/^(\Q$0\E) \1$/$1/m,/ \Q$0\E$/m||s/^\Q$0\E\s//gm&print$0while/^\S+/gm;$_&&die
89.50 Michael Thelen Wed Jul 3 23:45:47 2002
-ln0 s/^(.*) \1$/$1/mg;/ \Q$&
/||($t=print$&)&s/^\Q$&\E\s//mgwhile/\S+/g;$t--?//&&redo:&a
Changed 'die' to &a (undefined sub). I've tried three completely different approaches and this one's still worked the best, but I'm not so confident in it anymore.
89.51 Wladimir Palant Thu Jul 4 22:25:40 2002
-0 $_=<>;s/^(\S+) \1$/$1/mg;/ \Q$&\E$/m||print("$&\n"),s/^\Q$&\E\s//gmwhile/\S+/g;//&&die
89.52 Juuso Salonen Thu Jul 4 16:13:15 2002
-ln0 s//
/;0//(\S+)/g,/(?<!
\Q$1\E) \Q$1
/?3:do{$a=$1;s/
(\Q$1\E\s)+/
/g;print$a}while/./
never gonna catch me, Wladimir! :)
90.46 Amir Karger Sun Jul 7 04:36:58 2002
-ln0 A1:for$n(split){$c="\Q$n\E\\s";/^(?!$c).+ $c/m||s/^($c)?$c//gm&goto A.print$n}$_&&die
The .02 lead seemed a bit too slim, so...
90.49 Michael Thelen Wed Jul 3 03:47:24 2002
-ln0 s/^(.*) \1$/$1/mg;/ \Q$&
/||($t=print$&)&s/^\Q$&\E\s//mgwhile/\S+/g;$t--?//&&redo:die
Ditched the outer while loop for a 3 stroke gain. Yay!
90.52 Mtv Europe Fri Jul 5 20:28:52 2002
-lan0 s/^(\S+) \1$/$1/mg;/ \Q$&
/||print($&)&&s/^\Q$&\E[ 
]//mg&&redo while/\S+/g;/./&&die
hmm, i was surprised that it works since sometimes $& $+ $- and so on are dying so unexpectedly.
90.57 Stephen Turner Sun Jul 7 11:47:40 2002
-lan0 for$a((@F)x y/
//){$b="\Q$a";/^(?!$b ).* $b
/m||s/^$b( $b
| |
)//mg&&print$a}$_&&die
91.46 Amir Karger Sun Jul 7 04:34:32 2002
-ln0 A1:for$n(split){$c="\Q$n\E\\s";/^(?!$c)\S+ $c/m||s/^($c)?$c//gm&goto A.print$n}$_&&die
It's getting uglier and uglier, but I'm going to slip back into tenth!
91.48 Keith Calvert Ivey Sat Jul 6 02:42:02 2002
-ln0 s/^(.+) \1$/$1/gm;s/^\Q$"\E\s//gm,print$"while$"=$_,($")=grep$"!~/ \Q$_
/,split;S/!/./
Saved a space by changing $s to $"
91.57 Stephen Turner Sun Jul 7 11:17:01 2002
-lan0 for$a((@F)x y/
//){$b="\Q$a";/^(?!$b ).* $b
/m||s/^$b( $b
| |
)//mg&&print$a}/./&&die
92.37 Keith Calvert Ivey Wed Jul 3 23:34:29 2002
-ln0 s/^(.+) \1$/$1/gm;s/^\Q$s\E\s//gm,print$s while$s=$_,($s)=grep$s!~/ \Q$_
/,split;S/!/./
It's now possible to change the for(;;) to a while modifier. Doesn't save any strokes, but lowers the tiebreaker.
92.38 Keith Calvert Ivey Wed Jul 3 13:16:35 2002
-ln0 for(s;^(.+) \1$;$1;gm;$s=$_,($s)=grep$s!~/ \Q$_
/,split;print$s){s}^\Q$s\E\s}}gm}S/!/./
Moved print to save a stroke, then added gratuitous obfuscation
92.43 Amir Karger Fri Jul 5 15:53:03 2002
-ln0 A1:for$n(split){$c="\Q$n\E";s/^$c $c$/$n/gm;/ $c\n/||s/^$c\s//gm&goto A.print$n}$_&&die
Squeeeeeeezing...
92.47 Ala Qumsieh Thu Jul 4 04:35:05 2002
-ln0 s/^(.*) \1$/$1/mg;
while(/^\S+/mg){/^.* \Q$&\E
/ms||print$&and s/^\Q$&\E\s//gm}
$_&&die
Don't ask me how I did .. it just happened!
92.50 Juho Snellman Wed Jul 3 19:50:05 2002
-ln0 $_ x=2;{s%^(\S+)\s(?!\C*^(?!\1 ).+ \1
)%print$1;s-(^| )(\Q$1\E\s)+-$1&&die-meg;redo%em}
This is just my 82 stroke solution with extra checks. I haven't constructed a test which the 82 doesn't pass, but I'm pretty sure there is one.
92.55 Wladimir Palant Thu Jul 4 22:23:19 2002
-0 $_=<>;s/^(\S+) \1$/$1/mg;/ \Q$&\E$/m||print("$&\n"),s/^\Q$&\E( |$)//gmwhile/\S+/g;//&&die
92.57 Stephen Turner Sat Jul 6 09:01:41 2002
-lan0 for$a((@F)x y/
//){$b="\Q$a";/^(?!$b ).* $b
/m||s/^$b( ($b
)?|
)//mg&&print$a}/./&&die
93.46 Keith Calvert Ivey Wed Jul 3 12:51:14 2002
-ln0 for(s/^(.+) \1$/$1/gm;$s=$_,($a)=grep$s!~/ \Q$_
/,/\S+/g;print$a){s/^\Q$a\E\s//gm}t/!/./
93.49 Michael Thelen Wed Jul 3 03:39:03 2002
-ln0 s/^(.*) \1$/$1/mg;${/ \Q$&
/||($t=print$&)&s/^\Q$&\E\s//mgwhile/\S+/g;$t--||die}while/./
None of my other algorithms have panned out, so I'll just keep pushing parentheses around...
94.45 Amir Karger Fri Jul 5 04:10:31 2002
-ln0 s/^(.+) \1$/$1/gm;A:for$n(split){$c="\Q$n\E\\s";/ $c/||s/^$c//gm&print($n)&goto A}$_&&die
We've broken the 100 barrier! And I'm in the top 10 for what might be the first time ever.
94.46 Juho Snellman Tue Jul 2 18:18:12 2002
-ln0 $_ x=2;{s%^(\S+)\s(?!.*((?!\1)\S+) \1
)%sqrt$;{$1}--;print$1;s|^(\Q$1\E\s)*||mg;redo%sem}
Sandtrap-insurance.
94.48 Qingning Huo Tue Jul 2 10:19:57 2002
-ln0 ($y=$&)=~s/\W/\\$&/g,s/^($y) $y$/$1/m,/ $y$/m||s/^($y)\s//gm&print$1while/^\S+/gm;$_&&die
I should have found this earlier.
95.48 Qingning Huo Tue Jul 2 05:55:26 2002
-ln0 ($y=$&)=~s/\W/\\$&/g,s/^($y) $y$/$1/m,!/ $y$/m&&s/^($y)\s//gm&print$1while/^\S+/gm;$_&&die
95.50 Michael Thelen Wed Jul 3 02:04:33 2002
-ln0 s/^(.*) \1$/$1/mg;${/ \Q$&
/||s/^(\Q$&\E)\s//mg&($t=print$1)while/\S+/g;$t--||die}while/./
Except for the obvious improvement of removing unnecessary /m modifiers, I've hit a wall.
96.48 Qingning Huo Tue Jul 2 05:59:18 2002
-ln0 ($y=$&)=~s/\W/\\$&/g,s/^($y) $y$/$1/gm,!/ $y$/m&&s/^($y)\s//gm&print$1while/^\S+/gm;$_&&die
do we need /g in the second RE?
96.52 Qingning Huo Mon Jul 1 22:44:12 2002
-ln0 ($y=$&)=~s/\W/\\$&/g,!/^(.+) (?!\1$)$y$/m&&s/^($y)\s($y
)?//gm&print$1while/^\S+/gm;$_&&die
and again.
96.59 Eugene van der Pijll Mon Jul 8 01:55:23 2002
-lan0 sub f{1/!$g{$_}++;$p{$_}||=map(&f,$x=~/^(.*) (?!\1
)\Q$_
/mg)+print;$g{$_}=0}$x=$_;f for@F
97.47 Jukka Suomela Fri Jul 5 21:55:27 2002
-alp ($_,my$y)=map{bless$x{$_}||=[$_]}@F;$_-$y&&push@$_,$y}DESTROY{$d?dump:print$_[0][0]}{$d=%x=q
97.49 Michael Thelen Tue Jul 2 21:32:12 2002
-ln0 s/^(.*) \1$/$1/mg;${/ \Q$&
/m||s/^(\Q$&\E)\s//mg&($t=print$1)while/\S+/mg;$t--||die}while/./
Inching closer...
97.53 Qingning Huo Mon Jul 1 22:41:33 2002
-ln0 ($y=$&)=~s/\W/\\$&/g,!/^(.+) (?!\1$)$y$/m&&s/^($y)\s($y
)?//gm&&print$1while/^\S+/gm;$_&&die
finally below 100.
97.55 pom Tue Jul 2 15:55:30 2002
-0777n s/^(.+) \1$/$1/gm;while(/^\S+/gm){if(!/ \Q$&\E$/m){print"$&
";s/^\Q$&\E[ 
]//gm}}/\S/&&die
Oops, this one should work better... Still under 100!
98.48 Chris Dolan Mon Jul 8 04:23:01 2002
-nal push@{$a{pop@F}},@F}map&a,keys%a;sub a{$z eq$_||0/$.--*&a*$.++for@{$a{$z=$_}};$p{$_}++||print
This is just a minor improvement on my previous submission to remove the "die". It's a bit slow: takes about a minute on my 500MHz box.
98.57 Wladimir Palant Thu Jul 4 16:39:07 2002
-0 $_=<>;s/^(\S+) \1$/$1 /mg;/ \Q$1\E$/m||print("$1\n"),s/^\Q$&\E(.*)/$1 /gmwhile/(\S+) /g;//&&die
98.58 Eugene van der Pijll Mon Jul 8 01:46:45 2002
-lan0 sub f{1/!$g{$_}++;$p{$_}++or map(&f,$x=~/^(.*) (?!\1
)\Q$_
/mg),print;$g{$_}=0}$x=$_;f for@F
99.44 Albert Dvornik Wed Jul 3 23:10:42 2002
-ln01 s/^(.*) \1$/$1/mg;A:while($_){for$k(split){/ \Q$k\E$/m||s/^\Q$k\E\s//mg+print($k)+next
A}die}
Less than 100!
99.53 Michael Thelen Tue Jul 2 05:14:26 2002
-ln0 ${/^(?!\Q$&\E ).* \Q$&
/m||s/^(\Q$&\E)( \1)?\s//mg&($t=print$1)while/\S+/mg;$t--||die}while/./
Yay! Broke 100!
99.53 Juuso Salonen Thu Jul 4 15:52:00 2002
-ln0 s//
/;0//(\S+)/g,/(?<!
\Q$1\E) \Q$1
/?3:do{$a=$1;s/
(\Q$1\E\s)+/
/g;print$a;/./?3:exit}while 3
100.50 Jukka Suomela Tue Jul 2 19:20:48 2002
-ap my($x,$y)=map{$x{$_}||=bless[$_]}@F;$x-$y&&push@$x,$y}DESTROY{$0?$\.=$_[0][0].$/:dump}{%x=1;$0=0
100.57 Wladimir Palant Thu Jul 4 15:54:37 2002
-0 $_=<>;s/^(\S+) \1$/$1 /mg;/ \Q$1\E$/m||print("$1\n"),s/^\Q$&\E(.*)/$1 /gmwhile/(\S+) /g;/\S/&&die
101.53 Qingning Huo Mon Jul 1 18:20:44 2002
-ln0 ($y=$&)=~s/\W/\\$&/g,/$y/&!/^(.+) (?!\1$)$y$/m&&print($&)+s/^$y\s($y
)?//gmwhile/^\S+/gm;$_&&die
It's closer...
102.46 Jukka Suomela Tue Jul 2 18:35:55 2002
-ap my($x,$y)=map{$s{$_}||=bless[$_]}@F;$x==$y||push@$x,$y}DESTROY{$\.=$_[0][0].$/;$d&&dump}{%s=0;$d=1
102.50 Keith Calvert Ivey Wed Jul 3 12:37:21 2002
-ln0 for(s/^(.+) \1$/$1 /gm;$s=$_,($a)=grep$s!~/ \Q$_
/,/\S+/g;){s/^\Q$a\E (.*)/$1 /gm;print$a}t/!/\S/
102.53 Qingning Huo Mon Jul 1 18:03:47 2002
-ln0 ($y=$&)=~s/\W/\\$&/g,/$y/&!/^(\S+) (?!\1$)$y$/m&&print($&)&s/^$y\s($y
)?//gmwhile/^\S+/gm;$_&&die
can I pass 100?
102.53 Michael Thelen Tue Jul 2 05:01:49 2002
-ln0 ${/^(?!\Q$&\E ).* \Q$&\E$/m||s/^(\Q$&\E)( \1)?\s//mg&&($t=print$1)while/\S+/mg;$t--||die}while/./
More small improvements, hoping for the big one...
103.48 Chris Dolan Sun Jul 7 21:57:42 2002
-nal push@{$a{pop@F}},@F}map&a,keys%a;sub a{$z eq$_||($.--||die,&a,$.++)for@{$a{$z=$_}};$o{$_}++||print
Gained my stroke back
103.50 Chris Dolan Sun Jul 7 21:42:56 2002
-nal push@{$a{pop@F}},@F}&a for%a;sub a{$z eq$_||($.--||die,&a,$.++)for@{$a{$z=$_}};$o{$_}++.ref||print
104.48 Chris Dolan Sun Jul 7 21:55:35 2002
-nal push@{$a{pop@F}},@F}&a for keys%a;sub a{$z eq$_||($.--||die,&a,$.++)for@{$a{$z=$_}};$o{$_}++||print
This is one stroke longer than my best, but it runs 30% faster, so maybe the refs will like it better...
105.48 Chris Dolan Sun Jul 7 21:09:37 2002
-nal push@{$a{pop@F}},@F}sub a{$.--<0&&die;$z eq$_||&a for@{$a{$z=$_}};$.++;$o{$_}++||print}for(keys%a){a
105.53 Mtv Europe Fri Jul 5 19:05:40 2002
-ln0 s/^(\S+) \1$/$1/mg;$a=$_;A:die if map$a!~/ \Q$_\E
/&&print&&$a=~s/^\Q$_\E[ 
]//mg&&goto A,$a=~/\S+/g
my first attempt, not sure you will accept it since i use windows platform :)
106.47 Lars Mathiesen Tue Jul 2 14:57:24 2002
$_=join'',<>;s/^(.*) \1$/$1/mg;s/^\Q$y\E\s//mg,print"$y
"while$x=$_,($y)=grep$x!~/ \Q$_\E
/,split;/ /&&die
Grotty \Q\E, grotty fix for reflexives. Room for improvement...
106.50 Qingning Huo Mon Jul 1 17:36:37 2002
-ln0 while(/^\S+/gm){($y=$&)=~s/\W/\\$&/g;s/^$y\s($y\s)?//gm
if/$y/&!/^(\S+) (?!\1$)$y$/m&&print$&}$_&&die
Hope this works.
106.54 Michael Thelen Tue Jul 2 04:51:07 2002
-ln0 ${$t=0;/^(?!\Q$&\E ).* \Q$&\E$/m||s/^(\Q$&\E)( \1)?\s//mg&&++$t&&print$1while/\S+/mg;$t||die}while/./
Got rid of a few parens and braces... now to get rid of $t.
107.47 Juho Snellman Mon Jul 1 18:27:53 2002
-ln0 s/^(.+) \1$/$1/gm;$_.="\t
$_";s/^\Q$1\E\s//mgwhile
s/^(\S+)\s(?!.* \1
)(.*\t)/print$1;$2/mse;/\S/&&die
Ah, I should have remembered that regexes always win... :-)
108.47 Amir Karger Fri Jul 5 02:29:40 2002
-n0 s/^(\S+) \1$/$1/gm;
A:for$n (split){ 
if(!/ \Q$n\E\n/){
s/^\Q$n\E\s//gm;
print"$n\n";
goto A
}
}
$_&&die
Woo-hoo! Still got more to do...
108.49 David Lowe Wed Jul 3 23:34:47 2002
-lna @w{@F}=@F;push@g,$_}{&%if map{print,delete$w{$w},redo
if$w=$_,!grep/ \Q$w\E$/&&$`ne$w&&$w{$`}ne'',@g}%w
108.53 Juuso Salonen Thu Jul 4 15:09:57 2002
-ln0 s//
/;/(\S+)/g,($a=$1)=~//?/(?<!
\Q$a\E) \Q$a
/?3:do{s/
(\Q$a\E\s)+/
/g;print$a;/./?3:exit}:3/$/while+3
108.55 Sec Wed Jul 3 09:45:31 2002
-lap @t{@q{@F}=@F}.=" $F[0] "x!/^\Q$F[1] /}for(keys%q){1/(($_)=grep!$t{$_},%q);$t{$w=$_}+=map{s/ \Q$w //g}%t
Who had thought that even "die" could be made shorter ;-)
108.56 Eugene van der Pijll Mon Jul 8 01:39:16 2002
-lan0 sub f{$g{$_}++&&&g;$p{$_}++or map(&f,$x=~/(.*) \Q$_
/g),print;$g{$_}=0}s/^(.*) \1$/$1/mg;$x=$_;f for@F
109.59 Wladimir Palant Thu Jul 4 15:51:03 2002
-0 $_=<>;s/^(\S+) \1$/$1 /mg;/ \Q$1\E$/m||$a{$1}++||print("$1\n"),s/^\Q$&\E(.*)/$1 /mwhile/(\S+) /g;/\S/&&die
110.49 Keith Calvert Ivey Wed Jul 3 12:33:21 2002
-p0 for(s/^(.+) \1$/$1 /gm;$s=$_,($a)=grep$s!~/ \Q$_
/,/(.+) /g;){s/^\Q$a\E (.*)/$1 /gm;s/\z/$a
/}s/\s+///!/ /
110.49 David Lowe Wed Jul 3 23:25:43 2002
-lna @w{@F}=@F;push@g,"@F"}{&%if map{print,delete$w{$w},redo
if$w=$_,!grep/ \Q$w\E$/&&$`ne$w&&$w{$`}ne'',@g}%w
pass the test, dammit
110.53 Michael Thelen Tue Jul 2 04:35:57 2002
-ln0 ${$t=0;for$m(/^\S+/mg){/^(?!\Q$m\E ).* \Q$m\E$/m||s/^(\Q$m\E)( \1)?\s//mg&&++$t&&print$m}$t||die}while/./
111.49 Chris Dolan Thu Jul 4 05:08:55 2002
-nal push@{$a{pop@F}},@F}sub a{$c{$_}++&&die;$z eq$_||&a for@{$a{$z=$_}};$c{$_}--;$o{$_}++||print}for(keys%a){a
Make heavy use of default var. Yahoo!
111.51 Juuso Salonen Wed Jul 3 16:59:43 2002
-ln0 s//
/;/(\S+)/g,($a=$1)=~//?/(?<!
\Q$a\E) \Q$a
/?0:do{while(s/^\Q$a\E\s//m){}print$a;//?3:exit}:3/$/while+3
111.53 Michael Thelen Tue Jul 2 03:50:57 2002
-ln0 while(/./){$t=0;for$m(/^\S+/mg){/^(?!\Q$m\E ).* \Q$m\E$/m||s/^(\Q$m\E)( \1)?\s//mg&&++$t&&print$m}$t||die}
I think a regex is the way to go for this one. But it's dang hard to construct! (This isn't it:-)
111.54 Honza Pazdziora Thu Jul 4 09:01:07 2002
-n0 s/\S+$/$&
$& $&/gm;X:for$x(/\S+/g){/^(?!\Q$x\E ).+ \Q$x
/m or s/^\Q$x\E .*$//mg,(print"$x
"),goto X}/./&&&g
112.56 Terje K Sun Jul 7 04:23:55 2002
-nl $h{_}{$'}=/ /;$h{$'}{$`}=1if$`ne$'}{sub z{$u{$_}++&&die,$y{$_}||=z($_)+print,$u{$_}--for keys%{$h{+pop}}}z _
113.54 Eugene van der Pijll Mon Jul 8 00:12:57 2002
-lap0 $_ x=@F;s#(.*) (.*)#$g{$2}>($g{$1}x=1)||log@F-($g{$2}=$g{$1}+($1ne$2))#ge}for(sort{$g{$a}<=>$g{$b}}keys%g){
113.56 Eugene van der Pijll Mon Jul 8 01:25:42 2002
-lan0 sub f{$g{$_}++&&&g;if(!$p{$_}++){&f for $x=~/(.*) \Q$_\E\n/g;print}$g{$_}=0}s/^(.*) \1$/$1/mg;$x=$_;f for@F
Eureka!
113.56 Terje K Sat Jul 6 18:42:38 2002
-nl $h{$;}{$'}=/ /;$h{$'}{$`}=1if$`ne$'}{sub z{$u{$_}++&&die,$y{$_}++||z($_)&print,$u{$_}--for keys%{$h{+pop}}}z$
114.51 Keith Calvert Ivey Wed Jul 3 12:04:07 2002
-p0 for(s/ (.+)/$&
$1 /g,s/^(.+) \1
//gm;$s=$_,($a)=grep$s!~/ \Q$_
/,/(.+) /g;){s/^\Q$a\E .*
//gm;s/\z/$a
/}t/!/ /
Saved a stroke with for(;;) in place of while().
114.53 Eugene van der Pijll Mon Jul 8 00:04:59 2002
-lap0 $_ x=@F;s#(.*) (.*)#$g{$2}>($g{$1}x=1)or@F>($g{$2}=$g{$1}+($1ne$2))or&f#ge}for(sort{$g{$a}<=>$g{$b}}keys%g){
114.53 Jasper McCrea Fri Jul 5 14:54:21 2002
-lp0 @e{@a=split}=1;$o=join$\,keys%e;1/!eval'grep/ /&$o=~s#^(\Q$\'\E)$((.|
)*
)(\Q$`\E)$#$4$2$1#m,/.*/g;'x@a;$_=$o
mmm.. bacon..
114.54 Eugene van der Pijll Sun Jul 7 23:22:12 2002
-lap0 $_ x=@F;s#(.*) (.*)#$g{$2}>($g{$1}x=1)or($g{$2}=$g{$1}+($1ne$2))<@F||&f#ge}for(sort{$g{$a}<=>$g{$b}}keys%g){
114.55 Stephen Turner Fri Jul 5 22:01:07 2002
-ln0 map{for$a(/\S+/gm){$b="\Q$a";/^(?!$b ).* $b$/m||s/^$b(?!\S) ?//mg&&print($a)&s/^$b$//mg}}($_)x y/
//;/./&&die
Down to only 1.75 * Ton's score.
114.56 Terje K Sat Jul 6 15:05:41 2002
-nl $h{$"}{$'}=/ /;$h{$'}{$`}=1if$`ne$'}{sub z{$u{$_}++&&die,$y{$_}++||z($_)&print,$u{$_}--for keys%{$h{+pop}}}z$"
115.51 Keith Calvert Ivey Wed Jul 3 03:46:12 2002
-p0 s/ (.+)/$&
$1 /g;s/^(.+) \1
//gm;while($s=$_,($a)=grep$s!~/ \Q$_
/,/(.+) /g){s/^\Q$a\E .*
//gm;s/\z/$a
/}t/!/ /
Found a better way of dying.
115.54 Sec Tue Jul 2 20:26:34 2002
-lap @t{@F}.=" $F[0] "if$F[0]ne$F[1];@q{@F}=@F}for(keys%q){(($_)=grep!$t{$_},%q)||die;$t{$,=$_}+=map{s/ \Q$, //g}%t
I tried using grep a few times already. But suddenly it gave a gain %)
115.57 Terje K Sat Jul 6 14:53:38 2002
-nl $h{$"}{$'}=/ /;$h{$'}{$`}=1if$`ne$'}{sub z{map{$u{$_}++&&die,$y{$_}++||z($_)&print,$u{$_}--}keys%{$h{+pop}}}z$"
115.65 Terje K Sat Jul 6 13:02:56 2002
-nl $h{$'}{$"}=/ /;$h{$`}{$'}=$`ne$'}{sub z{map$h{$_}{$_[0]}&&($u{$_}++&&die,$y{$_}++||z($_)&print,$u{$_}--),%h}z$"
116.55 Honza Pazdziora Wed Jul 3 14:53:11 2002
-n0 s/\S+$/$&
$& $&/gm;X:for$x(/(.+) /mg){/^(?!\Q$x\E ).+ \Q$x\E$/m or s/^\Q$x\E .*$//mg,print("$x
"),goto X}/./&&&g
117.49 Amir Karger Wed Jul 3 20:49:54 2002
-nal $p{$l}{$r}=($l,$r)=@F;$p{$r}{$r}=0}{sub z{keys%p}for(z){for$%(z){delete$p{$%},print$%if!grep$p{$_}{$%},z}}z&&die
Not good for my tiebreak score, but...
117.50 Keith Calvert Ivey Wed Jul 3 03:42:37 2002
-p0 s/ (.+)/$&
$1 /g;s/^(.+) \1
//gm;while($s=$_,($a)=grep$s!~/ \Q$_
/,/(.+) /g){s/^\Q$a\E .*
//gm;s/\z/$a
/}/ /&&die
117.57 Andrew Savige Mon Jul 8 04:17:01 2002
-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&&&
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.
117.65 Terje K Sat Jul 6 13:00:12 2002
-nl / /;$h{$'}{$"}=1;$h{$`}{$'}=$`ne$'}{sub z{map$h{$_}{$_[0]}&&($u{$_}++&&die,$y{$_}++||z($_)&print,$u{$_}--),%h}z$"
118.47 Juho Snellman Mon Jul 1 15:53:49 2002
@a=<>;{map{s/^(.+) \1$/$1/;if((($a)=split)&&!grep/ \Q$a\E$/,@a){print"$a
";s/^\Q$a\E\s//for@a;redo}}@a}map/\S/&&die,@a
I'm afraid that this isn't how Ton did his 88, but at least it takes me to unshared second place... Well, back to the drawing board.
118.48 Chris Dolan Thu Jul 4 04:45:39 2002
-nal push@{$a{$F[1]}},@F}sub a{$c{my$z=pop}++&&die;$z eq$_||a($_)for@{$a{$z}};$c{$z}--;$o{$z}++||print}for(keys%a){a$_
Lucky bonus: last item in for is self, so $_ is already set (saves me two strokes)
118.55 Yanick Champoux Sun Jul 7 16:45:28 2002
-lpa push@;,[@F[$F[0]eq$_..1]]for@F}while(/.+/,map{@$_=grep$&ne$_,@$_}@;){($_)=map{(($x)=@$_)x!grep$$_[1]eq$x,@;}@;or&
Would that dirty trick be my final swing at this hole?
118.57 Andrew Savige Sun Jul 7 23:15:52 2002
-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&&&
Caught `/ at last! Will he respond though?
118.59 Wladimir Palant Thu Jul 4 15:21:33 2002
-0 $_=<>;s/^(\S+) \1$/$1 /mg;while(/^(\S+) /mg){$a{$1}++||print("$1\n"),s/^\Q$1\E (.*)/$1 /m if!/ \Q$1\E$/m};/\S/&&die
119.54 Yanick Champoux Sat Jul 6 03:13:33 2002
-lpa push@a,[@F[$F[0]eq$_..1]]for@F}while(/.+/,map{@$_=grep$&ne$_,@$_}@a){($_)=map{(($x)=@$_)x!grep$$_[1]eq$x,@a}@a or&
Woohoo! Sub-120!
119.55 Honza Pazdziora Wed Jul 3 14:00:51 2002
-n0 s/\S+$/$&
$& $&/gm;X:{for$x(/^(.+) /mg){/^(?!\Q$x\E ).+ \Q$x\E$/m or s/^\Q$x\E .*$//mg,print("$x
"),redo X}/./&&&g}
120.48 Chris Dolan Wed Jul 3 21:51:06 2002
-nal sub a{$c{my$z=pop}++&&die;$z eq$_||a($_)for@{$a{$z}};$c{$z}--;$o{$z}++||print$z}push@{$a{$F[1]}},@F}for(keys%a){a$_
Oops, extra copy-n-paste space
120.48 Amir Karger Wed Jul 3 19:50:48 2002
-nal $p{$l}{$r}=($l,$r)=@F;$p{$r}{$r}=0}{sub z{keys%p}for(z){for$n(z){grep{$p{$_}{$n}}z or delete$p{$n},print$n}}%p&&die
Probably my limit for a while. I removed \n's for a "true" best score.
121.48 Chris Dolan Wed Jul 3 21:50:43 2002
-nal sub a{$c{my$z=pop}++&&die;$z eq$_||a($_)for@{$a{$z}};$c{$z}--;$o{$z}++||print$z}
push@{$a{$F[1]}},@F}for(keys%a){a$_
Shaving...
121.55 Keith Calvert Ivey Tue Jul 2 13:09:05 2002
-p0 s/ (.+)/$&
$1 /g;s/^(.+) \1
//gm;while(%f=/ (.+)(
)/g,($a)=grep!$f{$_},/(.+) /g){s/^\Q$a\E .*
//gm;s/\z/$a
/}/ /&&die
121.55 Eugene van der Pijll Sun Jul 7 23:12:26 2002
-lap0 @g{@F}=0;$_ x=@o=keys%g;s#(.*) (.*)#$g{$2}>$g{$1}or($g{$2}=$g{$1}+($1ne$2))<@o||&f#ge}for(sort{$g{$a}<=>$g{$b}}@o){
121.56 Andrew Savige Sun Jul 7 22:54:33 2002
-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&&&
Still fighting! Puff! Puff! I've got to get into shape for these vigorous sprints to the finish line. Hope `/ is worried.
121.66 Terje K Sat Jul 6 12:54:01 2002
-nl /(.+) /;$h{$'}{$"}=1;$h{$1}{$'}=$1ne$'}{sub z{map$h{$_}{$_[0]}&&($u{$_}++&&die,$y{$_}++||z($_)&print,$u{$_}--),%h}z$"
122.51 Sec Tue Jul 2 19:41:02 2002
-lan @t{@F}.=" $F[0] "if$F[0]ne$F[1];@q{@F}=@F}for(keys%q){map$t{$_}||do{$t{$,=$_}+=print;map{s/ \Q$, //g}%t;next},%q;die;
My last solution is actually invalid according to the rules (see seperate mail for a test case). Fix it.
122.52 Scott Hall Sun Jul 7 17:55:23 2002
-nl / /;$f{$_}++||push@{$a{$'}},$`eq$'?():$`}sub v{$b{$_}++?die:&v,--$b{$_}for@{$a{$_}};$p{$_}++||print}for(keys%a){my%b;v
122.55 Keith Calvert Ivey Tue Jul 2 12:06:40 2002
-p0 s/ (.+)
/$&$1 
/g;s/^(.+) \1
//gm;while(%f=/ (.+)(
)/g,($a)=grep!$f{$_},/(.+) /g){s/^\Q$a\E .*
//gm;s/\z/$a
/}/ /&&die
Had to change $ to \z to handle the new case with just "a a".
122.58 Jasper McCrea Thu Jul 4 15:05:32 2002
-lp0 @e{/\S+/g}=1;$o=join"
",keys%e;1/!eval'grep/(\S+) (\S+)/&$o=~s/^(\Q$2\E)$((.|
)*)^(\Q$1\E)$/$4$2$1/m,/.*/g;'x99;$_=$o
passes on 1.8 for me, anyway. Of course, this does not assure that the solution is valid :)
122.60 Wladimir Palant Thu Jul 4 15:16:31 2002
-0 $_=<>;s/^(\S+) \1$/$1 /mg;while(/^(\S+) (.*)/mg){$a{$1}++||print("$1\n"),s/^\Q$1\E (.*)/$1 /m if!/ \Q$1\E$/m};/\S/&&die
122.66 Terje K Fri Jul 5 08:11:15 2002
-nl /(.+) /;$h{$'}{$"}=1;$h{$1}{$'}=$1ne$'}{sub z{map$h{$_}{$_[0]}&&($u{$_}++&&die,$y{$_}++||z($_)&&print,$u{$_}--),%h}z$"
123.50 Jonathan Stimmel Mon Jul 8 00:54:24 2002
-ln / /;$`ne$'?$r{$'}{$`}:$x=$r{$`}||={}}while(@n=grep!%{$r{$_}}&&print,keys%r or%r&&exit 1){map delete@$_{@n},\%r,values%r
123.52 Wladimir Palant Wed Jul 3 23:59:05 2002
-0 $_=<>;@a=/\S+/g;s/^(\S+) \1$//mg;for$a(@a){s/^\Q$a\E (.+)/push@a,$1;''/mge,$a{$a}++||print"$a\n"if!/ \Q$a\E$/m}/\S/&&die
123.53 Jasper McCrea Fri Jul 5 11:47:56 2002
-lp0 @e{@a=split}=1;$o=join$\,keys%e;1/!eval'grep/(\S+) (\S+)/&$o=~s/^(\Q$2\E)$((.|
)*)^(\Q$1\E)$/$4$2$1/m,/.*/g;'x@a;$_=$o
Although a baconiser does sound like a good idea.
123.57 Andrew Savige Sun Jul 7 04:27:16 2002
-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&&&
This is a really ugly solution. I hope, however, it makes `/ just a wee bit scared. :-)
123.57 Jasper McCrea Wed Jul 3 14:45:33 2002
-lp0 @e{/\S+/g}=1;$o=join"
",keys%e;$_=eval'grep/(\S+) (\S+)/&$o=~s/^(\Q$2\E)$((.|
)*)^(\Q$1\E)$/$4$2$1/m,/.*/g;'x99?die:$o
hurrah! I join the ranks of those whose score is less than twice Ton's!
123.60 Aj Mon Jul 8 04:59:27 2002
-l map{/ (.*)/,($o{$`}+=0)<$o{$1}or$`eq$1or$o{$1}=$o{$`}+1,o/($o{$1}<$.)}(<>)x++$.;for$i(0..$.){map$o{$_}^$i||print,keys%o}
124.49 Chris Dolan Wed Jul 3 21:40:28 2002
-nal sub a{$c{my$z=pop}++&&die;$z eq$_||a($_)for@{$a{$z}};$c{$z}--;$o{$z}++||print$z}push@{$a{$F[1]}},@F}map{%c=a$_}keys%a;{
Breakthrough! At last!!!
124.52 Wladimir Palant Wed Jul 3 23:20:06 2002
-0 $_=<>;@a=/\S+/mg;s/^(\S+) \1$//mg;for$a(@a){s/^\Q$a\E (.+)/push@a,$1;''/mge,$a{$a}++||print"$a\n"if!/ \Q$a\E$/m}/\S/&&die
124.56 Stephen Turner Wed Jul 3 20:59:54 2002
-l map{(grep{/ \Q$a\E$/&!/^\Q$a /}@0)||(print$a)&&map{s/^\Q$a //;s/^\Q$a\E$//}@0if($a)=/(\S+)/}@0for@0=<>,@0;"@0"=~/\S/&&die
Completely different method, but not much better.
124.56 Eugene van der Pijll Tue Jul 2 01:24:36 2002
-lap0 @g{@F}=a;$_ x=@o=keys%g;$2eq$1||$g{$2}>$g{$1}||a/(($g{$2}=$g{$1}+1)<@o)while/(.*) (.*)/g}for(sort{$g{$a}<=>$g{$b}}@o){
124.57 Jasper McCrea Thu Jul 4 15:43:40 2002
-lp0 @e{/\S+/g}=1;$o=join$\,@l=keys%e;1/!eval'grep/(\S+) (\S+)/&$o=~s/^(\Q$2\E)$((.|
)*)^(\Q$1\E)$/$4$2$1/m,/.*/g;'x@l;$_=$o
curse you referees, and your insane love of non-hard-coded limits! p.s. I am not convinced that 'baconise' is a word.
125.52 Honza Pazdziora Wed Jul 3 12:05:52 2002
-alp ($,,$b)=@F;$l{$b}||=[];$,ne$b&&push@{$l{$,}},$b}while(%l){(($_)=grep{$*=$_;!grep$*eq$_,map@$_,%l}keys%l)?delete$l{$_}:&g
125.52 Jon Coppeard Sat Jul 6 22:07:45 2002
-n / /;$p{$a=$`.$/}+=0;$' eq$a or$p{$'}++,push@$a,$'}{delete$p{$_},print,map--$p{$_},@$_ while($_)=grep!$p{$_},keys%p;%p&&die
125.53 Scott Hall Sun Jul 7 14:08:09 2002
-nl / /;$f{$_}++||push@{$a{$'}},$`eq$'?():$`}sub v{$b{$_}++?die:v($_),--$b{$_}for@{$a{$_}};$p{$_}++||print}for(keys%a){my%b;v
125.53 Wladimir Palant Wed Jul 3 22:52:53 2002
-0 $_=<>;@a=/\S+/mg;s/^(\S+) \1$//mg;for$a(@a){/ \Q$a\E$/m||(s/^\Q$a\E (.+)/push@a,$1;''/mge,$a{$a}++||print"$a\n")}/\S/&&die
126.45 David Lowe Mon Jul 1 21:58:20 2002
-lna push@g,[@w{@F}=@F]}{(map{print(delete$w{$w}),redo
if$w=$_,!grep{$$_[0]ne$w&&exists$w{$$_[0]}&&$w eq$$_[1]}@g}keys%w)&&die
126.47 Wladimir Palant Wed Jul 3 17:26:59 2002
-nal push@a,[@F]if$F[0]ne$F[1];@a{@F}=(1)x2}{a while delete@a{grep{$a=$_;print if!grep$$_[1]eq$a&$a{$$_[0]},@a}keys%a};%a&&die
126.48 Juho Snellman Mon Jul 1 15:11:55 2002
@a=<>;{map{s/^(.+) \1$/$1/;($a,$b)=split;if(/\S/&&!grep/ \Q$a\E$/,@a){
print"$a
";s/^\Q$a\E\s//for@a;redo}}@a}map{/\S/&&die}@a
Regexp metacharacters should work now.
126.48 pom Mon Jul 1 12:03:47 2002
-ln / /;++$b{$'}{$`}if$`ne$';$b{$`}||={}}{map delete@{%$_}{@d},values%b while delete@b{@d=grep!%{$b{$_}}&&print,keys%b};exit%b
Again, by a hair!
126.49 Michael Thelen Mon Jul 1 17:09:32 2002
-ln / /,$`ne$'&&$b{$'}{$`}++;$b{$`}{0}}while(%b){delete@b{@k=grep!%{$b{$_}}&&print,keys%b}or die;delete@{$b{$_}}{@k}for keys%b
126.49 Albert Dvornik Fri Jul 5 21:17:30 2002
-ln0 $l=$_;sub X{my$x=$_;$v{$x}++&&return;@r=map$_ eq$x?():X(),$l=~/^(.*) \Q$x\E$/mg;$v{$x}>1&&die;@r,$x}print for map X,split
A brand new search-based approach. Can this get me closer to The Amazing Mr. Hospel? >=)
127.50 Honza Pazdziora Wed Jul 3 11:23:32 2002
-alp ($a,$b)=@F;$l{$b}||=[];push@{$l{$a}},$b if$a ne$b}while(%l){(($_)=grep{$*=$_;!grep$*eq$_,map@$_,%l}keys%l)?delete$l{$_}:&g
127.52 Martin Carlsen Tue Jul 2 08:25:06 2002
-p0 $n++>8*y///c&&die while
s/^((\S+) \S+
)(.*^(?!\2 )\S+ \2
)/$3$1/sm||s/( \S+)(
.*\1
)/$2/s||s/ /
/||s/^(\S+
)(.*^)\1/$1$2/ms
127.53 Geoff Hubbard Mon Jul 8 01:35:27 2002
-ln $r{$1}{$`}=/ (.*)/}{sub v{$c{$"=$_}=2;$_ ne$"and$c{$_}?$c{$_}^2||die:&v for keys%{$r{$_}};$c{$_}=print}$c{$_}||v for keys%r
128.44 David Lowe Mon Jul 1 21:30:08 2002
-lna push@g,[@w{@F}=@F]}O:{for$w(keys%w){print(delete$w{$w}),redo O
if!grep{$$_[0]ne$w&&exists$w{$$_[0]}&&$w eq$$_[1]}@g}%w&&die
128.48 Martin Carlsen Mon Jul 1 18:44:55 2002
-nl / /;\$p{$`};$`eq$'||++$p{$'}^push@{$s{$`}},$'}{1while map{delete$p{$_};--$p{$_}for@{$s{$_}};print}grep!$p{$_},keys%p;%p&&die
128.53 Andrew Savige Sun Jul 7 02:03:51 2002
-aln @n{@F}+=!s/^(.+) \1$//&!$:{$_}++}{@l=grep!$n{$_},@m=keys%n;//,print,push@l,grep!--$n{$_},map/^\Q$'\E (.+)/,%:for@l;@l-@m&&&
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.
128.61 Aj Sun Jul 7 19:09:39 2002
-l map{/ (.*)/,($o{$`}+=0)<($o{$1}+=0)or$`eq$1or$o{$1}=$o{$`}+1,o/($o{$1}<$.)}(<>)x++$.;for$i(0..$.){map$o{$_}^$i||print,keys%o}
128.62 Terje K Fri Jul 5 05:31:30 2002
-nl /(.+) /;$h{$'}{$"}=1;$h{$1}{$'}=$1ne$'}{sub z{my$x=pop;map$h{$_}{$x}&&{$u{$_}++&&die,$y{$_}++||z($_)&&print,$u{$_}--},%h}z$"
129.48 Wladimir Palant Wed Jul 3 16:27:04 2002
-nal push@a,[@F]if$F[0]ne$F[1];@a{@F}=(1,1)}{a while grep{$a=$_;delete$a{$a},print if!grep$$_[1]eq$a&$a{$$_[0]},@a}keys%a;%a&&die
129.49 Martin Carlsen Mon Jul 1 17:28:43 2002
-nl / /;\$p{$`};$`eq$'||++$p{$'}&&push@{$s{$`}},$'}{1while map{delete$p{$_};--$p{$_}for@{$s{$_}};print}grep!$p{$_},keys%p;%p&&die
129.51 Jon Coppeard Tue Jul 2 21:09:09 2002
-n / /;$p{$a=$`.$/}+=0;$a ne$'&&$p{$'}++,push@$a,$'}{@n=grep++$n&&!$p{$_},keys%p;--$n,print,push@n,grep!--$p{$_},@$_ for@n;exit$n
129.52 Wladimir Palant Wed Jul 3 22:10:38 2002
-0 $_=<>;@a=/^\S+/mg;s/^(\S+) \1$//mg;for$a(@a){/ \Q$a\E$/m&&next;$a{$a}++||print"$a\n";s/^\Q$a\E (.+)/push@a,$1;''/mge}/\S/&&die
130.44 Albert Dvornik Wed Jul 3 20:23:46 2002
-l @l=<>;A:while(grep$_,@l){for$k(map split,@l){!grep/ \Q$k\E$/&&!s/^\Q$k\E //,@l
and(map(s/^\Q$k\E\s//,@l),print($k),next A)}die}
130.47 TheodoreYoung Fri Jul 5 16:38:26 2002
-lan END{map{print;delete$C{$_}}grep{!grep{$C{$_}}keys%{$C{$_}}}keys%C or die while%C}($l,$r)=@F;$C{$l}{\n}=$l ne$r?$C{$r}{$l}=1:1
130.48 Andrew Savige Sun Jul 7 01:54:53 2002
-aln / /;$p{$_}++or@n{@F}+=$`ne$'&&!!push@{$s{$`}},$'}{@l=grep!$n{$_},@m=keys%n;print,push@l,grep!--$n{$_},@{$s{$_}}for@l;@l-@m&&&
Don't laugh! Not only does it have a better tie-breaker, it is faster too!
130.49 Stephen Turner Wed Jul 3 20:59:23 2002
-nla ($",$b)=@F;push@{$v{$"}},$;;$"eq$b||push@{$v{$b}},$"}{map{map{print,delete$v{$_}if!grep{$v{$_}}@{$v{$_}}}keys%v}0..$.;%v&&die
Not very good, but I like the expression grep{$v{$_}}@{$v{$_}}
130.52 Peter Haworth Fri Jul 5 18:15:09 2002
-nla push@v,($,,$r)=@F;$,eq$r||push@{$e{$r}},$,}sub v{$v{$_}=2;$v{$_}?$v{$_}&2&&die:&v for@{$e{$_}};$v{$_}=print}{$v{$_}||&v for@v
130.53 Andrew Savige Sat Jul 6 05:37:24 2002
-aln @n{@F}+=!s/^(.+) \1$//&!$:{$_}++}{@l=grep!$n{$_},@m=keys%n;/.+/,print,push@l,grep!--$n{$_},map/^\Q$&\E (.+)/,%:for@l;@l-@m&&&
130.54 Yanick Champoux Thu Jul 4 01:04:55 2002
-lpa push@a,[@F[$_..1]]for$F[0]eq$F[1],1}while(@a=grep!grep($x
eq$_,@$_),@a){$_=(($x)=map{($x=@$_[0])x!grep$$_[1]eq$x,@a}@a)?$x:&:
BWAH! I had forgotten about this über-dirty trick!
130.58 Aj Sun Jul 7 13:52:36 2002
-l $f=0,map{/ (.*)/,($o{$`}+=0)<($o{$1}+=0)or$`eq$1or$f=$o{$1}=$o{$`}+1}@0for(@0=<>,$,=$/);1/!$f,print sort{$o{$a}<=>$o{$b}}keys%o
131.49 Michael Thelen Mon Jul 1 15:34:55 2002
-ln / /,$`ne$'&&$b{$'}{$`}++;$b{$`}{0}}while(%b){delete@b{@k=grep!%{$b{$_}},keys%b}or die;delete@{$b{$_}}{@k}for keys%b;print for@k
More minor improvements... I need something less cumbersome than a HoH, methinks.
131.50 pom Mon Jul 1 11:08:13 2002
-ln / /;++$b{$'}{$`}if$`ne$';$b{$`}||={}}{while(delete@b{@d=grep{!%{$b{$_}}&&print}keys%b}){delete@{%{$b{$_}}}{@d}for keys%b}exit%b
By a hair...
131.50 Jon Coppeard Tue Jul 2 15:51:43 2002
-n / /;$p{$'}++,push@$a,$' if($a=$`.$/)ne$';$p{$a}+=0}{@n=grep++$n&&!$p{$_},keys%p;--$n,print,push@n,grep!--$p{$_},@$_ for@n;exit$n
131.51 Jonathan Stimmel Sun Jul 7 23:48:53 2002
-ln / /;$`ne$'?$r{$'}{$`}:$_=$r{$`}||={}}$,=$\;while(@n=grep!%{$r{$_}},keys%r or exit(%r>0)){map delete@$_{@n},\%r,values%r;print@n
131.53 Yanick Champoux Thu Jul 4 01:03:14 2002
-lpa push@a,[@F[$_..1]]for$F[0]eq$F[1],1}while(@a=grep!grep($x
eq$_,@$_),@a){$_=(($x)=map{($x=@$_[0])x!grep$$_[1]eq$x,@a}@a)?$x:die
Did I mentioned already how hilarious I find that grep!grep construct?
131.54 Geoff Hubbard Sun Jul 7 23:53:31 2002
-ln $r{$2}{$1}=/(.*) (.*)/}{sub v{$c{$"=$_}=2;$_ ne$"and$c{$_}?$c{$_}^2||die:&v for
keys%{$r{$_}};$c{$_}=print}$c{$_}||v for keys%r
131.62 Terje K Thu Jul 4 22:25:31 2002
-nl /(.+) /;$h{$'}{$"}=1;$h{$1}{$'}=1if$1ne$'}{sub z{my$x=pop;map$h{$_}{$x}&&{$u{$_}++&&die,$y{$_}++||z($_)&&print,$u{$_}--},%h}z$"
132.45 David Lowe Mon Jul 1 21:25:23 2002
-lna push@g,[@w{@F}=@F]}O:{for$w(keys%w){print(delete$w{$w}),redo O
if!grep{$$_[0]ne$$_[1]&&exists$w{$$_[0]}&&$w eq$$_[1]}@g}%w&&die
132.51 Honza Pazdziora Tue Jul 2 16:36:35 2002
-alp $l{$F[1]}||=[];push@{$l{$F[0]}},$F[1]if$F[0]ne$F[1]}while(%l){($_)=grep{$*=$_;!grep{$*eq$_}map@$_,%l}keys%l
or die;delete$l{$_}
132.52 Michael Robinson Sat Jul 6 04:21:29 2002
-nl @n{/(.+) (.+)/}|=n;$n{$2}+=$1ne$2;push@{$g{$1}},$2}{(map{$n{$_}--for@{$g{$_}};delete$n{$_};print}grep!$n{$_},keys%n)?redo:exit%n
133.47 Amir Karger Wed Jul 3 19:27:56 2002
-nal ($l,$r)=@F;
$p{$l}{$r}=1;$p{$r}{$r}=0
}
{
for(keys%p){
for$n(keys%p){
grep{$p{$_}{$n}}keys%p or delete$p{$n},print$n
}
}
%p&&die
If I can't get the fancy algorithm to work, I guess I'll try fixing the old one. It does put me ahead a few spots. But it seems clear I need yet another another new algorithm.
133.49 Wladimir Palant Wed Jul 3 16:07:04 2002
-nal push@a,[@F]if$F[0]ne$F[1];@a{@F}=(1,1)}{a while grep{$a=$_;delete$a{$_},print$a if!grep$_->[1]eq$a&$a{$_->[0]},@a}keys%a;%a&&die
133.51 pom Mon Jul 1 10:11:59 2002
-ln / /;++$b{$'}{$`}if$`ne$';$b{$`}||={}}{while(%b){delete@b{@d=grep{!%{$b{$_}}&&print}keys%b}||die;delete@{%{$b{$_}}}{@d}for keys%b}
Must... write... thesis... Must... not... play... golf... argl
133.52 Yanick Champoux Thu Jul 4 00:41:40 2002
-lna push@a,[@F[$_..1]]for$F[0]eq$F[1],1}while(@a=grep!grep($x eq$_,@$_),@a){(($x)=map{($x=$$_[0])x!grep$$_[1]eq$x,@a}@a)?print$x:die
gooble gooble gooble
133.52 Scott Hall Sun Jul 7 13:39:11 2002
-nla ($;,$a)=@F;$f{$_}++||push@{$a{$a}},$;eq$a?():$;}sub v{$b{$_}++?die:v($_),--$b{$_}for@{$a{$_}};$p{$_}++||print}for(keys%a){my%b;v
134.53 Peter Haworth Fri Jul 5 17:35:02 2002
-nla @v{($,,$r)=@F}=0;$,eq$r||push@{$e{$r}},$,}sub v{$v{$_}=2;$v{$_}?$v{$_}&2&&die:&v for@{$e{$_}};$v{$_}=print}{$v{$_}||&v for keys%v
Only a few strokes off. Need new algorithm
135.48 Wladimir Palant Wed Jul 3 14:24:23 2002
-anl push@a,[@F]if$F[0]ne$F[1];@a{@F}=(1,1)}{a while grep{$a=$_;delete$a{$_},print$a if!grep{$_->[1]eq$a&$a{$_->[0]}}@a}keys%a;die if%a
135.53 Scott Hall Sat Jul 6 17:59:11 2002
-nla ($;,$a)=@F;$f{$_}++||push@{$a{$a}},$;eq$a?():$;}
sub v{$b{$_}++?die:v($_),--$b{$_}for@{$a{$_}};$p{$_}++||print}
for(keys%a){my%b;v
135.54 Michael Robinson Wed Jul 3 02:47:50 2002
-nl @n{/(.+) (.+)/}||=0;$n{$2}+=$1ne$2;push@{$g{$1}},$2}{(map$n{$_}?():do{map$n{$_}--,@{$g{$_}};delete$n{$_};print},keys%n)?redo:exit%n
My problem is, when I switch to a different method, it always ends up *longer*.
135.61 Terje K Thu Jul 4 21:25:33 2002
-anl ($;,$~)=@F;$h{$~}{$"}=1;$h{$;}{$~}=1if$;ne$~}{sub z{my$x=pop;map$h{$_}{$x}&&{$u{$_}++&&die,$y{$_}++||z($_)&&print,$u{$_}--},%h}z$"
136.47 Michael Thelen Mon Jul 1 15:07:11 2002
-ln / /,$`ne$'&&$b{$'}{$`}++;$b{$`}{0}}while(%b){delete@b{@k=grep{!keys%{$b{$_}}}keys%b}or die;delete@{$b{$_}}{@k}for keys%b;print for@k
136.48 Jasper McCrea Wed Jul 3 11:39:38 2002
-ln0 @e{/\S+/g}=1;@a=keys%e;eval'$s=0;for$i(0..@a){for$j($i+1..@a){$s=@a[$i,$j]=@a[$j,$i]if/^\Q$a[$j] $a[$i]
/m}}'x@a;$s?die:print for@a
I have another solution in the pipeline, but those damn metacharacters are a right royal pain!!
136.51 Yanick Champoux Wed Jul 3 23:38:08 2002
-lna push@a,[@F[$_..1]]for$F[0]eq$F[1],1}while(@a=grep!grep($_ eq$x,@$_),@a){
(($x)=grep{$x=$_;!grep$$_[1]eq$x,@a}map@$_,@a)?print$x:die
What I wouldn't give to borrow Ton's brain for a few hours...
137.46 Andrew Savige Wed Jul 3 21:08:18 2002
-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
caught `/ again!
137.50 Yanick Champoux Wed Jul 3 15:49:40 2002
-lna push@a,[@F[$_..1]]for$F[0]eq$F[1],1}{($x)=grep{$x=$_;!grep$$_[1]eq$x,@a}map@$_,@a or die;print$x;redo if@a=grep!grep($_ eq$x,@$_),@a
Sec, okay. |3en, it's hard. But. /-\. will. *not* beat. me.
137.52 Honza Pazdziora Tue Jul 2 16:12:48 2002
-alp @h{@F}=@F;push@{$l{$F[0]}},$F[1]if$F[0]ne$F[1]}while(%h){($_)=grep{$*=$_;!grep{$*eq$_}map{@$_}%l}%h or die;delete$l{$_};delete$h{$_}
137.53 Benoît Chauvet Mon Jul 1 08:47:17 2002
-ln / /;$p{$'}+=$`ne$';$p{$`}|=0;$n{$`}.=$'.$;;END{{}while grep{$a+=print;map{$p{$_}--}$_,split$;,$n{$_}}grep!$p{$_},@a=keys%p;exit$a-@a}
First try. Not so difficult than tpr04 !
137.54 Peter Haworth Fri Jul 5 11:01:48 2002
-nla @v{($,,$r)=@F}=();$,eq$r||push@{$e{$r}},$,}sub
v{$v{$_}=1;$v{$_}?$v{$_}&1&&die:&v for@{$e{$_}};print;$v{$_}=2}{$v{$_}||&v for keys%v
Here's algorithm #3. I love google
137.58 Terje K Thu Jul 4 20:58:11 2002
-anl ($a,$b)=@F;$h{$b}{$"}=1;$h{$a}{$b}=1if$a ne$b}{sub z{my$x=pop;map{$h{$_}{$x}&&{$u{$_}++&&die,$y{$_}++||z($_)&&print,$u{$_}--}}%h}z$"
138.48 Jasper McCrea Tue Jul 2 17:06:05 2002
-ln0 @e{/\S+/g}=1;@a=keys%e;eval'$s=0;for$i(0..@a){for$j($i+1..@a){$s=@a[$i,$j]=@a[$j,$i]if/^\Q$a[$j] $a[$i]\E$/m}}'x@a;$s?die:print for@a
sorry 'bout that.
139.49 Ala Qumsieh Thu Jul 4 03:48:52 2002
-ln / /;$`eq$'||$s{$`}{$'}++||$p{$'}++;$p{$`}+=0}while(%p){@a=grep!$p{$_},keys%p or die;map{delete$p{$_};print;$p{$_}--for keys%{$s{$_}}}@a
Dunno how much more juice I can suck out of this ...
139.50 Jon Coppeard Mon Jul 1 20:41:20 2002
-nl12 / /;$p{$'}++,push@{$e{$`}},$' if$`ne$';$p{$`}+=0}{@n=grep!$p{$_},keys%p;delete$p{$_},print,push@n,grep!--$p{$_},@{$e{$_}}for@n;exit%p
139.57 Terje K Thu Jul 4 20:46:17 2002
-anl ($a,$b)=@F;$h{$b}{$"}=1;$h{$a}{$b}=1if$a ne$b}{sub z{my$x=pop;map{if($h{$_}{$x}){$u{$_}++&&die;$y{$_}++||z($_)&&print;$u{$_}--}}%h}z$"
140.47 Michael Thelen Mon Jul 1 15:02:14 2002
-lna / /&&$`ne$'&&$b{$'}{$`}++;$b{$`}||={}}while(%b){delete@b{@k=grep{!keys%{$b{$_}}}keys%b}or die;delete@{$b{$_}}{@k}for keys%b;print for@k
140.48 Amir Karger Wed Jul 3 13:15:24 2002
-nal ($l,$r)=@F;
$p{$l}{$r}=$p{$r}{$r}=1
}
{
for(keys%p){
for$n(keys%p){
grep{$_ ne$n&&$p{$_}{$n}}keys%p or delete$p{$n},print$n
}
}
%p&&die
Use -na with }{ trick. I fear this algorithm is nearing its end, though...
140.49 David Lowe Mon Jul 1 20:14:32 2002
-lna ($l,$r)=@F;$l
eq$r||++$g{$r}{$l};$g{$l}||={}}{map{if(!%{$g{$_}}){print;for$k(keys%g){delete$g{$k}{$_}}delete$g{$_};redo}}keys%g;%g&&die
140.52 Scott Hall Sat Jul 6 17:20:28 2002
-nla $f{$_}++&&next;($;,$a)=@F;push@{$a{$a}},$;eq$a?():$;}
sub v{$b{$_}++?die:v($_),--$b{$_}for@{$a{$_}};$p{$_}++||print}
for(keys%a){my%b;v
141.46 Chris Dolan Wed Jul 3 21:25:00 2002
-pal sub a{$c{my$z=pop}++&&die;$z eq$_||a($_)for@{$a{$z}};$c{$z}--;push@o,$z if!grep$_ eq$z,@o}push@{$a{$F[1]}},@F}map{%c=a$_}keys%a;for(@o){
The new test scripts are killing me...
142.46 Andrew Savige Wed Jul 3 15:23:03 2002
-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
142.51 Yanick Champoux Wed Jul 3 15:13:55 2002
-lna push@a,[@F[$_..1]]for$F[0]eq$F[1]..1}while((@a,$_)=grep!grep($_
eq$x,@$_),@a){($x)=grep{$x=$_;!grep$$_[1]eq$x,@a}map@$_,@a
or
die;print$x
So much for so little.
143.46 Andrew Savige Wed Jul 3 14:29:18 2002
-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
This is utter bilge and I have no idea why it works but I've finally caught `/ by a nostril. :)))
143.53 Yanick Champoux Wed Jul 3 02:20:27 2002
-lna push@a,[$F[1]],[@F[0..$F[0]ne$F[1]]]}while((@a,$_)=grep!grep($_
eq$y,@$_),@a){for$x(map@$_,@a){grep$_->[1]eq$x,@a
or$y=$_=$x}/./?print:die
For that '0 1' test case that blarged my score, I hate you of all my heart, and curse your name until the one hundred and twenty-seventh generation (inclusive).
143.57 Michael Robinson Mon Jul 1 23:43:00 2002
-n @n{/(.+) (.+)/}||=0;$1ne$2&&$n{$2}++;push@{$g{$1}},$2}{(map{$n{$_}?():do{map$n{$_}--,@{$g{$_}};delete$n{$_};print"$_
"}}keys%n)?redo:%n&&die
Just printing in the loop does save a few bytes.
144.39 Bruce Gray Thu Jul 4 19:36:32 2002
-lan ($l,$r)=@F;$s{$r}{$l}=1if$l ne$r;$s{$l}||={};END{while(($l)=grep!%{$s{$_}},keys%s){print$l;delete$s{$_}{$l}for keys%s;delete$s{$l}}%s&&die}
145.44 Dr. Mu Sun Jul 7 22:33:11 2002
-l -0 ($s=$\.<>)=~s/^(\S+) \1$/\1/gm;$s=~s/(\s)\Q$t[0]\E(?=\s)/$1/gm&&print$t[0]while@t=grep$s!~/\S \Q$_\E$/m,$s=~/^ *(\S+)(?:\s)/gm;exit$s=~/\S/
145.47 Honza Pazdziora Tue Jul 2 15:53:45 2002
-alp @h{@F}=@F;push@{$l{$F[0]}},$F[1]if$F[0]ne$F[1]}while(keys%h){($_)=grep{$*=$_;!grep{$*eq$_}map{@$_}%l}keys%h or die;delete$l{$_};delete$h{$_}
145.56 Eugene van der Pijll Tue Jul 2 00:04:37 2002
-lan00 $g{$_}+=$|--for@F;$g{$_}--for/^(.*) \1$/gm;for($y=@o=keys%g;$y-=@n;){for$x(@n=grep!$g{$_},@o){$g{$_}--||print for/^\Q$x\E (.*)/gm,$x}1/@n}
You don't often see a for(;;) loop in golf. It's slowly getting better, but I'll have to find a better algorithm.
146.44 Philippe Bricout Sun Jul 7 22:03:36 2002
@h{(split)}++for@t=<>;$v=join$/,keys%h,'';{($a,$b)=split,$c+=$v=~s/^\Q$b\E$(.*)^\Q$a\E$/$a${1}$b/msfor@t;$c?$c=0:last;++$h{$v}>1&&die;redo}print$v
147.44 Dr. Mu Sun Jul 7 18:41:52 2002
-l -0 ($s=$\.<>)=~s/^(\S+) \1$/\1/gm;while(@t=grep$s!~/\S \Q$_\E$/m,$s=~/^ *(\S+)(?:\s)/gm){$s=~s/(\s)\Q$t[0]\E(?=\s)/$1/gm;print$t[0]}exit$s=~/\S/
147.45 Michael Thelen Mon Jul 1 06:08:45 2002
-lna ($j,$k)=@F;$b{$k}{$j}=1if$j ne$k;$b{$j}||={}}while(%b){delete@b{@k=grep{!keys%{$b{$_}}}keys%b}or die;delete@{$b{$_}}{@k}for keys%b;print for@k
The solution still looks big and gross, but it's time for bed.
147.49 Ross Younger Fri Jul 5 13:08:28 2002
-alp @U{($a,$b)=@F}=0;$R{$b}{$a}=1if$a
ne$b}@U=keys%U;while(@U){@U=sort{%{$R{$a}}<=>%{$R{$b}}}@U;%{$R{$a=shift@U}}&&die;delete$R{$_}{$a}for@U;$_=$a
Yikes, changed my algorithm and only saved 7 strokes :-/
147.52 Wladimir Palant Wed Jul 3 14:04:06 2002
-anl push@a,[@F]if$F[0]ne$F[1];@_{@F}=(1,1)}{$b=1,map{$c=$_;if(!grep{$_->[1]eq$c&$_{$_->[0]}}@a){delete$_{$c},$b=0,print$c}}keys%_ until$b;die if%_
148.56 Eugene van der Pijll Mon Jul 1 23:54:51 2002
-lan00 $g{$_}+=$|--for@F;$g{$_}--for/^(.*) \1$/gm;for($y=@o=keys%g;$y-=@n;){1/(@n=grep!$g{$_},@o);for$x(@n){$g{$_}--||print for/^\Q$x\E (.*)/gm,$x}}
149.46 Jonathan Stimmel Sat Jul 6 00:37:38 2002
-ln / /;$` ne $'&&$r{$`}{$'}++;$r{$'}||={}}$,=$\;while(%r){my%n;@n{keys%r}++;map delete@n{keys%$_},values%r;%n?print grep delete$r{$_},keys%n:exit 1;
149.55 Ala Qumsieh Tue Jul 2 19:31:24 2002
-ln /^(.*) (.*)$/;$1eq$2||$_{$1}{$2}++||$e{$2}++;$e{$1}+=0}{@a=grep!$e{$_},keys%e or die;map{print;delete$e{$_};map$e{$_}--,keys%{$_{$_}}}@a;%e&&redo
not much ... but better ..
150.46 Jon Coppeard Mon Jul 1 19:16:11 2002
-nl12 ($a,$b)=split;$p{$b}++,push@{$e{$a}},$b if$a ne$b;$p{$a}+=0}{@n=grep!$p{$_},keys%p;delete$p{$_},print,push@n,grep!--$p{$_},@{$e{$_}}for@n;exit%p
150.55 Eugene van der Pijll Mon Jul 1 23:29:33 2002
-lan00 $g{$_}+=$|--for@F;$g{$_}--for/^(.*) \1$/gm;while(grep$g{$_}>=0,@F){1/(@n=grep!$g{$_},keys%g);for$x(@n){$g{$_}--||print for/^\Q$x\E (.*)/gm,$x}}
151.46 Damien Neil Tue Jul 2 23:18:19 2002
-lna $M{$F[0]}||={};@{$M{$F[1]}}{@F}=1;END{while(keys%M>0){($n)=grep{keys%{$M{$_}}<=1}keys%M or die;print$n;delete$M{$n};map{delete$_->{$n}}values%M;}}
Initial what-the-hey solution, just to get something in there.
152.47 Amir Karger Fri Jul 5 02:18:04 2002
-n0 s/^(\S+) \1$/$1/gm;
$a=1;
while ($a--) {
for $node (split) { 
if (!/ \Q$node\E\n/) {
s/^\Q$node\E\s//gm;
print "$node\n";
$a=1;
last
}
}
}
die if $_
This is It! The One True Algorithm! This version is still somewhat readable; let's work on that.
152.50 Josef Drexler Thu Jul 4 19:33:12 2002
-lna @v{($@,$b)=@F}=0;push@{$e{$@}},$@ne$b?$b:()}sub d{my($x,$o)=@_;$r{$x}++&&die;$o+=1+d($_)for@{$e{$x}};$r{$x}--;$o}map print,sort{d($b)- d$a}keys%v;{
152.52 Amir Karger Wed Jul 3 13:17:54 2002
-pal @a{($l,$r)=@F}=@F;
$p{$r}{$l}=1if$l ne$r
}
while(($n)=grep!%{$p{$_}},%a){
delete$p{$_}{$n}for%p;
delete$a{$n};
print$n
}
for(keys%a){%{$p{$_}}&&die
YAAWWPGMN (Yet another algorithm which will probably get me nowhere.)
153.44 Michael Thelen Mon Jul 1 05:40:04 2002
-lna ($j,$k)=@F;$b{$k}{$j}=1if$j ne$k;$b{$j}||={}}while(%b){@k=grep{!keys%{$b{$_}}}keys%b;@k||die;delete@b{@k};delete@{$b{$_}}{@k} for keys%b;print for@k
Not bad for 40 minutes' work, I suppose. Lots of easy improvements, and probably many more to be made.
153.49 David Lowe Mon Jul 1 19:09:18 2002
-lna ($l,$r)=@F;$l eq$r||++$g{$r}{$l};$g{$l}or$g{$l}={}}O:if(%g){for(keys%g){if(!%{$g{$_}}){print;for$k(keys%g){delete$g{$k}{$_}}delete$g{$_};goto O}}die
First pass
153.50 Philippe Bricout Sat Jul 6 12:34:18 2002
@t=map{chop;/ /;@h{$',$`}++;"\$v=~s/^\Q$'\E\$(.*)^\Q$`\E\$/$`\${1}$'/ms"}<>;$v=join$/,keys%h,'';{$b+=eval for@t;$b?$b=0:last;++$h{$v}>1&&die;redo}print$v
153.55 Eugene van der Pijll Mon Jul 1 22:58:41 2002
-lan00 $g{$_}+=$|--for@F;$g{$_}--for/^(.*) \1$/gm;while(grep$g{$_}>=0,@@=keys%g){@n=grep!$g{$_},@@or&x;for$x(@n){print$x;$g{$_}--for/^\Q$x\E (.*)/gm,$x}}
Undefined subroutine &main::x called...
154.48 Andrew Savige Wed Jul 3 07:47:49 2002
-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
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.
154.53 Ross Younger Tue Jul 2 22:11:28 2002
-alp @U{@F}=0;push@{$L{$F[0]}},pop@F}sub v{$U{my$a=$_}=2;$_ eq$a||1<$U{$_}&&die||$U{$_}||&v for@{$L{$a}};--$U{$a};@O=($a,@O)}$U{$_}||v for keys%U;for(@O){
155.48 Andrew Savige Wed Jul 3 07:45:34 2002
-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
Shuffling deck chairs on the Titanic. And yet I am enjoying it in a perverse kind of way.
155.49 FatPhil Wed Jul 3 15:21:29 2002
-n / (\S+)/;$p{$1}.=" $` "if$`ne$1;$p{$`}x=1}for(;;@f=()){map{@f||$p{$_}||print+@f=$_,$/}keys%p;@f?delete$p{$f[0]}:each%p?die:last;map s/ \Q@f //g,values%p
$f -> @f. Phew, half of my drop clawed back.
156.42 Yanick Champoux Tue Jul 2 15:46:47 2002
-pa push@{$s{$F[0]}},$F[1]if$F[0]ne$F[1];$s{$F[1]}||=[]}{while(($x)=grep!@{$s{$_}},keys%s){$\="$x
".$\;map{@$_=grep$_
ne$x,@$_}values%s;delete$s{$x}}%s&&die
*whistling that 'Barber of Seville' tune*
156.57 Michael Robinson Mon Jul 1 11:15:44 2002
-n @n{/(.+) (.+)/}||=0;$1ne$2&&$n{$2}++,push@{$g{$1}},$2}{$c=0;map{$n{$_}||do{$c=$o.="$_
";map$n{$_}--,@{$g{$_}};delete$n{$_}}}keys%n;$c?redo:%n?die:print$o
157.45 Jonathan Stimmel Fri Jul 5 05:57:29 2002
-lna ($l,$r)=@F;$l ne $r&&$r{$l}{$r}++;$r{$r}||={}}$,=$\;while(%r){my%n;@n{keys%r}++;map delete@n{keys%$_},values%r;%n?print grep delete$r{$_},keys%n:exit 1;
157.49 Brad Jones Tue Jul 2 04:58:59 2002
-nl ($",$b)=split;$"ne$b&&$l{$b}->{$"}++;$l{$"}||={};END{while(%l){(($c)=grep{!%{$l{$_}}}keys%l)||die;print$c;delete$l{$c};for(keys%l){delete$l{$_}->{$c};}}}
157.51 Michael Wrenn Sun Jul 7 05:45:41 2002
-lan @u{@F}=@_=(@_,$_)}{@u=keys%u;while(!@g&(++$h<1E4||die$h)){for(@_){@c{@u}=0..@u;@g=($x,$y)=@c{+split};if($x>$y){@u[@g]=@u[$y,$x];@g=();last}}}print for@u
Movin' on up to the back of the pack! Now I need to find another new algorithm!Got any suggestions? Damn those time-wasting hashes! They were way too much fun! Great Hole Rick & company!
157.51 Wladimir Palant Wed Jul 3 13:42:44 2002
-anl push@a,[@F]if$F[0]ne$F[1];@_{@F}=(1,1)}{$b=1,map{$c=1;foreach$d(@a){$c=0if$d->[1]eq$_&$_{$d->[0]}}delete$_{$_},$b=0,print$_ if$c}keys%_ until$b;die if%_
158.47 Amir Karger Tue Jul 2 21:29:43 2002
-l while (<>) {
($l,$r)=split;
$p{$l}{$r}=$p{$r}{$r}=1
}
for(keys%p) {
for$n(keys%p) {
grep{$_ ne$n&&$p{$_}{$n}} keys%p or delete $p{$n},print$n
}
}
die if %p
Ha! I've caught up to Andrew! Too bad this algorithm is going nowhere.
158.47 Daniel Cutter Thu Jul 4 21:38:30 2002
-na $a{$_}++for($a,$b)=@F;push@r,qr/( \Q$b\E\n)(.*)( \Q$a\E\n)/s;END{$e.=" $_\n"for keys%a;for(@r){$e=~s/$_/$3$2$1/for@r}$e=~$_&&die for@r;$e=~s/ //g;print$e}
159.48 FatPhil Wed Jul 3 14:51:36 2002
-n / (\S+)/;$p{$1}.=" $` "if$`ne$1;$p{$`}x=1}for(;;$f=''){map{''ne$f||$p{$_}||print$f=$_,$/}keys%p;''ne$f?delete$p{$f}:each%p?die:last;map s/ \Q$f //g,values%p
Hoorah, getting longer!
159.51 Prakash Kailasa Mon Jul 8 03:59:11 2002
-lan push@{$h{$F[0]}},$F[1];$h{$F[1]}||=[]}{sub d{my($w,$x)=@_;$c{$w}||=1+do{map{$d++>$.&&&,,$x+=d($_)if$_ ne$w}@{$h{$w}};$x}}map{print}sort{d($b)<=>d$a}keys%h
159.53 Philippe 'BooK' Bruhat Thu Jul 4 12:23:30 2002
-lna END{do{for(@a=grep{!$a{$_}}keys%a){$a{$_}--for$a=~/$;\Q$_\E (\S+)^I/g;delete$a{$_};print}%a&&!@a&&die}while%a}$a{pop@F}+=$_ for($F[0]ne$F[1],0);$a.="$;$_^I"
A whole new approach, using a classical algorithm. Gained a dozen strokes, but still far behind.
160.48 Daniel Cutter Thu Jul 4 21:24:09 2002
-na $a{$_}++for($a,$b)=@F;push@r,qr/( \Q$b\E\n)(.*)( \Q$a\E\n)/s;END{$e.=" $_\n"for keys%a;for(@r){$e=~s/$_/$3$2$1/for@r}$e=~/$_/&&die for@r;$e=~s/ //g;print$e}
160.49 Prakash Kailasa Mon Jul 8 03:34:03 2002
-lan push@{$h{$F[0]}},$F[1];$h{$F[1]}||=[]}{sub d{my$w=pop;my$x=1;$c{$w}||=do{map{$d++>$.&&&,,$x+=d($_)if$_ ne$w}@{$h{$w}};$x}}map{print}sort{d($b)<=>d$a}keys%h
just 100 more than The Alien :-)
160.52 Eugene van der Pijll Mon Jul 1 22:44:58 2002
-ln00 $g{$_}+=$|--for/\S+/g;$g{$_}--for/^(.*) \1$/gm;while(grep$g{$_}>=0,keys%g){@n=grep!$g{$_},keys%g or die;for$x(@n){print$x;$g{$_}--for/^\Q$x\E (.*)/gm,$x}}
Grrrr... ugly solution... much too long... can't see anything shorter... really don't like this course... grrrr.
161.47 Brad Jones Tue Jul 2 04:07:55 2002
-nl ($",$b)=split;$"ne$b&&$l{$b}->{$"}++;$l{$"}||={};END{while(%l){(($c)=grep{!keys%{$l{$_}}}keys%l)||die;print$c;delete$l{$c};for(keys%l){delete$l{$_}->{$c};}}}
162.45 Peter Haworth Thu Jul 4 17:49:37 2002
-nla $p{$_}+=0for($,,$r)=@F;$,eq$r||++$p{$r}+push@{$s{$,}},$r}for(@q=grep!$p{$_},keys%p;@q;push@q,grep!--$p{$_},@{$s{
$_}}){print$_=pop@q}die if grep$_,values%p;{
162.46 Jonathan Stimmel Fri Jul 5 04:40:43 2002
-lna ($l,$r)=@F;$l ne $r&&$r{$l}{$r}++;$r{$r}||={}}$,=$\;while(%r){my%n;@n{keys%r}++;map delete@n{keys %$_},values %r;%n||exit 1;print grep delete$r{$_},keys(%n);
164.41 Yanick Champoux Tue Jul 2 01:07:46 2002
-na END{while(($x)=grep!@{$s{$_}},keys%s){$\="$x
".$\;map{@$_=grep$_
ne$x,@$_}values%s;delete$s{$x}}%s?die:print}push@{$s{$F[0]}},$F[1]if$F[0]ne$F[1];$s{$F[1]}||=[]
Okay, enough for tonight.
164.48 Brad Jones Tue Jul 2 02:28:54 2002
-nl ($",$b)=split;($"ne$b)&&$l{$b}->{$"}++;$l{$"}||={};END{while(%l){(($c)=grep{!keys%{$l{$_}}}keys%l)||die;print$c;delete$l{$c};for(keys%l){delete $l{$_}->{$c};}}}
165.58 Michael Robinson Mon Jul 1 09:20:37 2002
-n /(.+) (.+)/;$1ne$2&&$n{$2}++,push@{$g{$1}},$2;@n{$1,$2}||=()}{$c=0;map{$n{$_}||do{map$n{$_}--,@{$g{$_}};$c=$o.="$_
";delete$n{$_}}}keys%n;$c&&redo;%n&&die;print$o
Not very good translation of tsort(1) from BSD, with minor tweaks.
166.52 Philippe Bricout Thu Jul 4 22:01:43 2002
@t=map{s/(.*) (.*)
/\$v=~s\/^\Q$2\E\$(.*)^\Q${1}\E\$\/$1\${1}$2\/ms/;@h{$1,$2}++;$_}<>;$v=join"
",keys%h,'';{$b+=eval for@t;$b||last;++$h{$v}>1&&die;$b=0;redo}print$v
167.46 Marcelo E. Magallon Sat Jul 6 12:32:46 2002
-ln @p{($a,$b)=split}||={};next if$a eq$b;$p{$b}{$a}=1}{L:while(@k=keys%p){for(@k){next if keys%{$p{$_}};for$k(@k){delete$p{$k}{$_};}delete$p{$_};print;next L}exit 1;}
What am I doing in the alien league? I'm submitting this shameful solution only because I don't want to let another TPR course fly by.
167.53 Philippe 'BooK' Bruhat Thu Jul 4 14:37:07 2002
-lna END{@a=keys%a;T:$b=~/\Q@a/&&die;map{($c,$d)=@$_;@a{@a}=0..@a;$b.="^I@a",@a[@a{@$_}]=@a[@a{$d,$c}],goto
T if$a{$c}>$a{$d}}@r;$"=$/;print"@a";exit}push@r,[@a{@F}=@F]
s/for/map/ to shave a stroke. Test 27 takes time and memory, but it passes.
168.41 Yanick Champoux Tue Jul 2 00:55:00 2002
-na END{N:for$x(grep!@{$s{$_}},keys%s){$\="$x
".$\;map{@$_=grep$_
ne$x,@$_}values%s;delete$s{$x};goto
N}%s?die:print}push@{$s{$F[0]}},$F[1]if$F[0]ne$F[1];$s{$F[1]}||=[]
Not very efficient, but I find it cute, in an unwholesome manner.
168.52 Ala Qumsieh Tue Jul 2 18:57:59 2002
-lna $F[0]eq$F[1]||$_{$F[0]}{$F[1]}++||$e{$F[1]}++;$e{$F[0]}+=0}while(@b=keys%e){if (@a=grep!$e{$_},@b){for (@a){print;delete$e{$_};$e{$_}--for keys%{$_{$_}}}}else{die}
At least this one works. Major changes coming up ..
168.53 Philippe 'BooK' Bruhat Thu Jul 4 13:55:37 2002
-lna END{@a=keys%a;T:$b=~/\Q@a/&&die;for(@r){($c,$d)=@$_;@a{@a}=0..@a;$b.="^I@a",@a[@a{@$_}]=@a[@a{$d,$c}],goto
T if$a{$c}>$a{$d}}$"=$/;print"@a";exit}push@r,[@a{@F}=@F]
Well after all, this is a sort. So I used a classic approach to sorting: swap elements that are in the wrong order. And keep a list of everything we tried. If we try the same thing twice, then there's a loop. For the record, test 27 requires 3587 swaps, and the string that stores all the possibilities we tried is 6675407 bytes long.
169.47 Andrew Savige Tue Jul 2 11:18:27 2002
-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
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.
169.50 Josef Drexler Thu Jul 4 20:22:12 2002
-lna @v{($@,$b)=@F}=0;$e{$@}{$b}++if$@ne$b}sub d{$r{$_}++&&die,$o{$_}||=1+(sort{$b-$a}map d($_),keys%{$e{$_}})[0],$r{$_}--for@_;@o{@_}}map print,sort{d($b)- d$a}keys%v;{
this one's a lot faster...
173.52 Wladimir Palant Wed Jul 3 13:03:50 2002
-anl push@a,[@F]if$F[0]ne$F[1];$_{$F[0]}=$_{$F[1]}=1;END{$b=1,map{$c=1;foreach$d(@a){$c=0if($d->[1]eq$_&&$_{$d->[0]})}delete$_{$_},$b=0,print$_ if$c}keys%_ until$b;die if%_}
173.57 Philippe 'BooK' Bruhat Wed Jul 3 13:47:14 2002
-lna ($0,$b)=@F;$0ne$b&&!$0{$0}{$b}&&$r{$b}++;$0{$0}{$b}=$0{$b}||={};END{while(@a=keys%0){(@_=grep{!$r{$_}}@a)||die;for(@_){$r{$_}--for$_,keys%{$0{$_}};print;delete$0{$_}}}}
Removed the sub that's called once.
176.43 Yanick Champoux Tue Jul 2 00:12:45 2002
-na END{N:if(@z=keys%s){for$x(@z){@{$s{$x}}&&next;$\="$x
".$\;$_=[grep$_
ne$x,@$_]for
values%s;delete$s{$x};goto N}die}print}push@{$s{$F[0]}},$F[1]if$F[0]ne$F[1];$s{$F[1]}||=[]
Of course, using a string and regexes is probably the way to go. But arrays want love, too!
176.46 Bruce Gray Mon Jul 1 17:59:27 2002
-lan my($l,$r)=@F;$n{$l}+=0;next if$l eq$r;++$n{$r};push@{$s{$l}},$r;END{@_=grep{!$n{$_}}keys%n;while(@_){$_=pop@_;print;push@_,grep!--$n{$_},@{$s{$_}}}$n{$_}&&die for keys %n}
178.52 Prakash Kailasa Mon Jul 8 02:14:10 2002
-lan $i{$_}++||push@{$h{$F[1]}},$F[0];$h{$F[0]}||=[]}{sub d{my($w,$d,$x)=@_;$c{$w}||=do{map{$d>$.&&die,$x+=1+d($_,++$d)if$_ ne$w}@{$h{$w}};$x}}map{print}sort{d($a)<=>d($b)}keys%h
I refuse to end this on sandtrap. This one's longer but should zip through the tests.
179.52 Philippe 'BooK' Bruhat Wed Jul 3 12:18:08 2002
-lna ($0,$b)=@F;$0ne$b&&!$0{$0}{$b}&&$r{$b}++;$0{$0}{$b}=$0{$b}||={};sub
a{@_||die'';for(@_){$r{$_}--for$_,keys%{$0{$_}};print;delete$0{$_}}}END{a grep{!$r{$_}}keys%0while keys%0}
Removed the index variable from a for loop.
181.00 Michael Thelen Mon Jul 1 05:27:52 2002
-l while(<>){($j,$k)=split;$j ne$k&&($b{$k}{$j}=1);$b{$j}||={}}while(%b){@k=grep{keys%{$b{$_}}==0}keys%b;exit(-1)if!@k;delete @b{@k};for$k(keys%b){delete$b{$k}{$_}for@k}print for@k}
Boy, it's not at all pretty, but it's a first shot.
183.51 Philippe 'BooK' Bruhat Wed Jul 3 12:13:11 2002
-lna ($0,$b)=@F;$0ne$b&&!$0{$0}{$b}&&$r{$b}++;$0{$0}{$b}=$0{$b}||={};sub a{@_||die'';for$a(@_){$r{$_}--for$a,keys%{$0{$a}};print$a;delete$0{$a}}}END{a grep{!$r{$_}}keys%0while keys%0}
Replaced $a by $0 for consiseness.
184.48 Daniel Cutter Thu Jul 4 19:54:16 2002
-an $a{$_}++for@F;($a,$b)=@F;push@r,qr/( \Q$b\E )(.*)( \Q$a\E )/ if$a ne$b;END{$e.=" $_ "for keys%a;for(1..keys%a){$e=~s/$_/$3$2$1/for@r}$e=~/$_/&&die for@r;print"$_\n"for split' ',$e}
185.49 Amir Karger Wed Jul 3 18:47:05 2002
-nal ($l,$r)=@F;
$p{$l}+=0;
$p{$r}++if$r ne$l&&!$c{$l}{$r}++
}
sub z{grep{!$p{$_}}@a=keys%p}
@o=z;
while(defined($_=pop@o)){
print;
push@o,grep{!--$p{$_}}keys%{$c{$_}}
}
die if z!=@a;
{
Hm. This new algorithm was supposed to gain me more ground...
185.49 Philippe 'BooK' Bruhat Wed Jul 3 12:07:59 2002
-lna ($a,$b)=@F;$a ne$b&&!$a{$a}{$b}&&$r{$b}++;$a{$a}{$b}=$a{$b}||={};sub a{@_||die'';for$a(@_){$r{$_}--for$a,keys%{$a{$a}};print$a;delete$a{$a}}}END{a grep{!$r{$_}}keys%a while keys%a}
Removed @F for consiseness.
190.46 Boyd Nation Sun Jul 7 04:04:00 2002
-l while(<>){chomp;($a,$b)=split;if($a ne$b){push(@{$s{$a}},$b);$p{$b}++}if(!$p{$a}){$p{$a}=0}}&H;sub H{for$v(keys%p){if(!$p{$v}){print$v;for$w(@{$s{$v}}){$p{$w}--}delete($p{$v});&H}}exit%p}
191.43 Yanick Champoux Mon Jul 1 15:23:46 2002
-lna END{N:while(@z=keys%s){for$x(@z){if(!@{$s{$x}}){@y=($x,@y);$s{$_}=[grep$_ ne$x,@{$s{$_}}]for@z;delete$s{$x};next N}}exit 1}print for@y}push@{$s{$F[0]}},$F[1]if$F[0]ne$F[1];$s{$F[1]}||=[]
Just testing the ground...
192.50 Brad Jones Tue Jul 2 00:32:29 2002
-nl ($",$b)=split;($"ne$b)&&push@{$l{$b}},$";$l{$"}||=[];END{while(%l){$o=0;for$c(keys%l){if(!@{$l{$c}}){print$c;$o++;delete$l{$c};for(keys%l){$l{$_}=[grep{$_ ne$c}@{$l{$_}}];}}}!$o&&exit 1;}}
193.49 Brad Jones Tue Jul 2 00:28:15 2002
-nl ($a,$b)=split;($a ne$b)&&push@{$l{$b}},$a;$l{$a}||=[];END{while(%l){$o=0;for$c(keys%l){if(!@{$l{$c}}){print$c;$o++;delete$l{$c};for(keys%l){$l{$_}=[grep{$_ ne$c}@{$l{$_}}];}}}!$o&&exit 1;}}
197.42 BigrTex Wed Jul 3 18:57:09 2002
-lna ($l,$r)=@F;exists$p{$_}?next:x;$v{$l}+=0;if($l ne$r){++$v{$r};push@{$s{$l}},$r}}@t=grep{!$v{$_}}keys%v;while(@t){print$z=pop@t;map{push@t,$_ unless--$v{$_}}@{$s{$z}}}if(grep{$v{$_}}keys%v){die
More fun with perldoc perlrun
197.51 Philippe 'BooK' Bruhat Wed Jul 3 12:04:29 2002
-lna $F[0]ne$F[1]&&!$a{$F[0]}{$F[1]}&&$r{$F[1]}++;$a{$F[0]}{$F[1]}=$a{$F[1]}||={};sub a{@_||die'';for$a(@_){$r{$_}--for$a,keys%{$a{$a}};print$a;delete$a{$a}}}END{a grep{!$r{$_}}keys%a while keys%a}
With the correct algorithm, it works much better... And I am below 200, too!
198.48 Daniel Cutter Thu Jul 4 14:41:33 2002
-an $a{$_}++for@F;($a,$b)=@F;push@r,qr/( \Q$b\E )(.*)( \Q$a\E )/ if$a ne$b;END{$e.=" $_ "for keys%a;for(1..@r*keys%a){$e=~s/$_/$3$2$1/for@r}for(@r){die if$e=~s/$_/$3$2$1/}print"$_\n"for split' ',$e}
199.41 BigrTex Wed Jul 3 18:54:05 2002
-ln ($l,$r)=split;exists$p{$_}?next:x;$v{$l}+=0;if($l ne$r){++$v{$r};push@{$s{$l}},$r}}@t=grep{!$v{$_}}keys%v;while(@t){print$z=pop@t;map{push@t,$_ unless--$v{$_}}@{$s{$z}}}if(grep{$v{$_}}keys%v){die
for becomes map, and I get under 200 strokes...
199.42 Erik Beatty Wed Jul 3 16:30:53 2002
while(<>){($p,$s)=split;$h{$s}.="\"$p\""if$p ne$s;$h{$p}.="";}$c=@k=keys%h;while(@k){$k=shift@k;if($h{$k}eq""){$c=@k;print"$k\n";map{$h{$_}=~s#"\Q$k\E"##g}@k;}else{push@k,$k;last if$c--<0;}}exit($c);
its just not human to go below the 100 mark.. how in the world did they do it? ;)
201.41 BigrTex Wed Jul 3 18:11:31 2002
-ln ($l,$r)=split;exists$p{$_}?next:x;$v{$l}+=0;if($l ne$r){++$v{$r};push@{$s{$l}},$r}}@t=grep{!$v{$_}}keys%v;while(@t){print$z=pop@t;for(@{$s{$z}}){push@t,$_ unless--$v{$_}}}if(grep{$v{$_}}keys%v){die
And for that matter, although you can't just concat $l and $r to index into $p, you could use $_...
203.39 Yanick Champoux Mon Jul 1 14:59:47 2002
-lna push@{$s{$F[0]}},$F[1]if$F[0]ne$F[1];$s{$F[1]}||=[];END{$,=$\;N:while(keys%s){for$x(keys%s){if(!@{$s{$x}}){unshift@y,$x;delete$s{$x};@{$s{$_}}=grep$_ ne$x,@{$s{$_}}for keys%s;next N}}exit 1}print@y}
It's a start...
205.41 BigrTex Wed Jul 3 18:10:28 2002
-ln ($l,$r)=split;exists$p{$l}{$r}?next:x;$v{$l}+=0;if($l ne$r){++$v{$r};push@{$s{$l}},$r}}@t=grep{!$v{$_}}keys%v;while(@t){print$z=pop@t;for(@{$s{$z}}){push@t,$_ unless--$v{$_}}}if(grep{$v{$_}}keys%v){die
exists should create $p{$l}{$r}, so you don't need to ++ it...
207.50 Wladimir Palant Wed Jul 3 10:42:54 2002
-anl push(@{$a{$F[1]}},$F[0])if$F[0]ne$F[1];push(@{$a{$F[0]}});END{$b=1;while($b){$b=0;map{$c=0;foreach$e(@{$a{$_}}){$c=1if!$d{$e};}if(!$d{$_}&&!$c){$d{$_}=1;print$_;$b=1;}}keys%a;}exit -1if keys%d!=keys%a;}
208.49 Matthias Schoder Fri Jul 5 14:11:55 2002
-lan012  ($x,$y)=@F;$X{$x}{$y}=$Y{$y}{$x}=1if$x ne$y;map{$N{$_}++}@F;END{exit map{map{if(!$Y{$_}){print;for$y(keys%Y){delete$Y{$y}{$_};delete$Y{$y}if!%{$Y{$y}}}delete$X{$_};delete$N{$_};exit if!%N}}keys%N}%N}
210.49 Matthias Schoder Fri Jul 5 14:02:40 2002
-lan012 ($x,$y)=@F;$X{$x}{$y}=$Y{$y}{$x}=1if$x ne$y;map{$N{$_}++}@F;END{exit map{map{if(!$Y{$_}){print;for$y(keys%Y){delete$Y{$y}{$_};delete$Y{$y}if!%{$Y{$y}}}delete$X{$_};delete$N{$_};exit if!%N}}keys%N}0..%N}
212.48 Brad Jones Tue Jul 2 00:08:02 2002
-nl ($a,$b)=split;($a ne$b)&&push@{$l{$b}},$a;$l{$a}||=[];END{while(%l){@j=sort{@{$l{$a}}<=>@{$l{$b}}}keys%l;$c=shift @j;(@{$l{$c}})&&exit(1);print$c;delete$l{$c};foreach$d(@j){$l{$d}=[grep{$_ ne$c}@{$l{$d}}];}}}
212.49 Matthias Schoder Fri Jul 5 13:00:18 2002
-lan012 ($x,$y)=@F;$X{$x}{$y}=$Y{$y}{$x}=1if$x ne$y;map{$N{$_}++}@F;END{map{map{if(!$Y{$_}){print;for$y(keys%Y){delete$Y{$y}{$_};delete$Y{$y}if!%{$Y{$y}}}delete$X{$_};delete$N{$_};exit if!%N}}keys%N}0..%N;exit 1}
212.54 Josef Drexler Wed Jul 3 22:32:38 2002
-lna $v{$F[1]}||=0;
($v{$F[0]},$e{$F[1]}{$F[0]})=1if$F[0]ne$F[1]
}
@%=keys%v;
sub d{
$r{$_}++&&die;
$o{$_}||=1+(sort{$b-$a}map{d()}keys%{$e{$_}})[0];
$r{$_}--;
$o{$_}
}
d for@%;
map print,sort{$o{$a}-$o{$b}}@%;
{
It's a start... it works. I left the newlines in to make it more readable. I'll golf it later...
215.50 Matthias Schoder Thu Jul 4 08:51:51 2002
-lan012 ($x,$y)=@F;$X{$x}{$y}=$Y{$y}{$x}=1if$x ne$y;map{$N{$_}++}@F;END{for(0..%N){for(keys%N){if(!$Y{$_}){print;for$y(keys%Y){delete$Y{$y}{$_};delete$Y{$y}if!%{$Y{$y}}}delete$X{$_};delete$N{$_};exit if!%N}}}exit 1}
216.42 BigrTex Wed Jul 3 17:57:35 2002
-ln ($l,$r)=split;exists$p{$l}{$r}?next:$p{$l}{$r}++;$v{$l}+=0;if($l ne$r){++$v{$r};push@{$s{$l}},$r}}@t=grep{!$v{$_}}keys%v;while(@t){print$z=pop@t;for(@{$s{$z}}){push@t,$_ unless--$v{$_}}}if(grep{$v{$_}}keys%v){die
A couple more strokes, since things aren't working at work... :(
219.42 BigrTex Wed Jul 3 16:15:01 2002
-ln ($l,$r)=split;exists$p{$l}{$r}?next:$p{$l}{$r}++;$v{$l}+=0;if($l ne$r){++$v{$r};push@{$s{$l}},$r}}@t=grep{!$v{$_}}keys%v;while(@t){$_=pop@t;print;for$c(@{$s{$_}}){push@t,$c unless--$v{$c}}}if(grep{$v{$_}}keys%v){die
*sighs* Dead last and trimming strokes slowly, not nearly quick enough. I don't know if you'll see any more submissions from me because of the long holiday weekend...
229.50 Wladimir Palant Wed Jul 3 10:17:31 2002
while(<>){chomp;split(/ /);push(@{$a{$_[1]}},$_[0])if$_[0]ne$_[1];push(@{$a{$_[0]}});}$b=1;while($b){$b=0;map{$c=0;foreach$e(@{$a{$_}}){$c=1if!$d{$e};}if(!$d{$_}&&!$c){$d{$_}=1;print"$_\n";$b=1;}}keys%a;}exit -1if keys%d!=keys%a;
First try
235.43 BigrTex Tue Jul 2 19:21:52 2002
-l while(<>){($l,$r)=@l=split;exists$p{$l}{$r}?next:$p{$l}{$r}++;$r{$l}+=0;if($l ne$r){++$r{$r};push@{$s{$l}},$r}}@t=grep{!$r{$_}}keys%r;while(@t){$_=pop@t;print;for$c(@{$s{$_}}){push@t,$c unless--$r{$c}}}if(grep{$r{$_}}keys%r){exit 1}
Another 65 strokes... variable names > 1 char are bad... :)
239.51 Michael Wrenn Sat Jul 6 15:35:13 2002
-lna z($~,($^,$~)=@F);map{for$^(k($_)){z($_,$^,$~)}}k($~);map{for$^(keys%k){$~eq$^&&die$!or&z($_,$_,$^)if$k{$^}{$~}}}k($~)}map{print}k(@p=sort{$c{$a}<=>$c{$b}}keys%k),@p;{sub z{$k{$a=pop}{+pop}||=++$c{$a}if$^ne$_[0]}sub k{keys%{$k{$_[0]}}}
That's all I have with hashes! This will give Kristen a moving target.
245.55 Philippe Bricout Wed Jul 3 21:24:56 2002
-l for (<>) {
^I($a,$b)=split;
^I@h{$a,$b}=();
^Inext if $a eq $b;
^I$i{$a,$b}=1
}
@t=keys %h;
if (keys %i){
^I$c=@t*@t;
^IO:for $p(0..$#t){
^I^Idie if !$c--;
^I^Ifor $j($p+1..$#t) {
^I^I^I@t[$p,$j]=@t[$j,$p],redo O if $i{$t[$j],$t[$p]}
^I^I}
^I}
}
print for @t
Les premiers seront les derniers et lycée de Versailles.
252.52 Michael Wrenn Thu Jul 4 22:10:35 2002
-lna &q($~,($^,$~)=@F);map{for$^(&k($_)){&q($~,$^,$_)}}&k($~);map{for$^(keys%k){$~eq$^&&die$!or&q($^,$_,$_)if$k{$^}{$~}}}&k($~)}@p=sort{$c{$a}<=>$c{$b}}keys%k;print for &k($p[0]),@p;{sub q{$k{$a=$_[0]}{$_[1]}||=++$c{$a}if$^ne pop}sub k{keys%{$k{+pop}}}
Can I go back to Beginner now? Do I at least get my choice of wooden spoons? At least I'm under 4A (4 x Alien)!
261.41 Amir Karger Tue Jul 2 21:05:21 2002
while (<>) {
    ($l, $r) = split;
    $pairs{$l}{$r} = 1;
    $pairs{$r}{$r} = 1;
}
for (keys %pairs) {
for $node (keys %pairs) {
next if (grep {$pairs{$_}{$node}} keys %pairs) - !!$pairs{$node}{$node};
print "$node\n";
delete $pairs{$node};
}
}
die if %pairs;
A bit shorter without the niceties. But is this shortenable by 150 or so? I doubt it.
265.46 Amir Karger Tue Jul 2 16:14:06 2002
$str = join"",<>;
1 while $str =~ s/^(\S+) \1$/$1/gm;
while ((($parent)=grep {!($str=~/ \Q$_\E$/m)} $str =~ /^(\S+) /gm)) {
    $str =~ s/^\Q$parent\E( (\S+)|\n)/$2/gme and print "$parent\n";
}
for($str=~/(\S+)/g){print "$_\n" unless $a{$_}++}
exit 1 if $str =~/ /;
This is the easy part...
267.47 Amir Karger Wed Jul 3 18:41:05 2002
-nal ($p, $c) = @F;
$parent{$p}+=0;
$parent{$c}++ if $c ne $p && !$child{$p}{$c}++
}
sub gr{grep{!$parent{$_}}@all=keys%parent}
@orphan = gr;
while (defined($_ = pop @orphan)) {
    print;
    push @orphan, grep{!--$parent{$_}} keys %{$child{$_}}
}
die if gr!=@all;
{
Ready or not, here I come!
289.49 Michael Wrenn Sat Jul 6 15:37:29 2002
-l while(<>){
chomp;
push(@l,$_);
}
for(@l){($s,$t)=split;$u{$s}=$u{$t}=1}
@u=keys%u;
$g=1;
while($g&&(++$h<50*@l||die$h)){
for(@l){
$g=0;
($j,$k)=split;
$x=z($j)-1;
$y=z($k)-1;
if($x>$y){@u[$x,$y]=@u[$y,$x];$g=1;last}
}
}
print for@u;
sub z {$c=0;for(@u){if($_[0] eq$u[$c++]){return$c}}0}
Before I do the fun part, does this pass? I tries hashes, regex and splice ... now swapping. Where am I supposed to find that magic algo?
301.38 BigrTex Tue Jul 2 19:12:37 2002
-l while(<>){($l,$r)=@l=split;exists$pairs{$l}{$r}?next:$pairs{$l}{$r}++;$npred{$l}+=0;if($l ne$r){++$npred{$r};push@{$succ{$l}},$r}}@list=grep{!$npred{$_}}keys%npred;while(@list){$_=pop@list;print;for$child(@{$succ{$_}}){push@list,$child unless--$npred{$child}}}if(grep{$npred{$_}}keys%npred){exit 1}
trimmed off 73 strokes (20%)... I'm on the board which is always nice, but I can't tell if I'll still be in the money on Sunday...
334.47 Amir Karger Wed Jul 3 18:32:39 2002
-nal ($p, $c) = @F;
$parent{$p}+=0;
next if $c eq $p;
$parent{$c}++ if !$child{$p}{$c}++
}
sub gr{grep{!$parent{$_}}@all=keys%parent}
@orphan = gr;
while (defined($node = pop @orphan)) {
    print "$node";
    for $kid (keys %{$child{$node}}) {
        $parent{$kid}--;
^Ipush @orphan, $kid if !$parent{$kid}
    }
}
die if gr!=@all;
{
Yet another another algorithm. This one stolen indirectly from Knuth.
374.42 BigrTex Tue Jul 2 18:56:35 2002
-l while(<>){
 my($l,$r)=my@l=split;
 next if defined $pairs{$l}{$r};
 $pairs{$l}{$r}++;
 $npred{$l}+=0;
if($l ne $r){ ++$npred{$r};
 push @{$succ{$l}},$r}}
my @list=grep{!$npred{$_}} keys %npred;
while (@list) {
 $_ = pop @list;
 print;
 foreach my $child (@{$succ{$_}}){
  unshift @list, $child unless --$npred{$child};
 }
}
if (grep {$npred{$_}} keys %npred) {
 exit 1;
}
It passed the 1.6 testcase... It's a lot shorter than a lot of the adjustments that I tried to make to accomodate those silly a->a loops... It's based on code from http://www.perl.com/language/ppt/src/tsort/tcsort.html
380.46 Kristen Thelen Thu Jul 4 07:13:18 2002
sub visit{my$z=$_[0];return if@{$l{$z}}[0]eq 2;exit 1if@{$l{$z}}[0]eq 1;@{$l{$z}}[0]=1;$c=0;foreach(@{$l{$z}}){visit($_)if$c ne 0;$c++}@{$l{$z}}[0]=2;unshift(@o,$z);}while(<>){($f,$s)=split;push@{$l{$f}},0if!@{$l{$f}};push@{$l{$s}},0if!@{$l{$s}};if($f ne$s){$g=0;$c=0;for (@{$l{$f}}){$g=1if($c ne 0)&&($_ eq$s);$c++}push @{$l{$f}}, $s if!$g;}}visit($_)for keys%l;print "$_
"for@o;
380.46 Kristen Thelen Thu Jul 4 15:47:25 2002
sub visit{my$z=$_[0];return if@{$l{$z}}[0]eq 2;exit 1if@{$l{$z}}[0]eq 1;@{$l{$z}}[0]=1;$c=0;foreach(@{$l{$z}}){visit($_)if$c ne 0;$c++}@{$l{$z}}[0]=2;unshift(@o,$z);}while(<>){($f,$s)=split;push@{$l{$f}},0if!@{$l{$f}};push@{$l{$s}},0if!@{$l{$s}};if($f ne$s){$g=0;$c=0;for (@{$l{$f}}){$g=1if($c ne 0)&&($_ eq$s);$c++}push @{$l{$f}}, $s if!$g;}}visit($_)for keys%l;print "$_
"for@o;
390.45 Peter Haworth Thu Jul 4 17:18:23 2002
-pla     ($l, $r) = @F;
    $npred {$_} += 0for@F;
    next if $l eq $r;
    $pairs{$l}{$r}++;
    ++$npred{$r};
    push @{$succ{$l}}, $r;
}

@list = grep !$npred{$_}, keys %npred;

while (@list) {
    $_ = pop @list;
    push @order,$_;
    foreach my $child (@{$succ{$_}}) {
      push @list, $child unless --$npred{$child};
    }
}
die if grep $npred{$_}, keys %npred;
$_=join$/,@order;

{
There I was thinking I needed recursion, when all I needed was to steal from tchrist's ppt :-) Lets see how easy this is to shorten
455.43 Amir Karger Tue Jul 2 16:08:31 2002
-w 
use strict;

my $str = join"",<>;
my $parent;
my $count;
# remove self-rules
1 while $str =~ s/^(\S+) \1$/$1/gm;
# While there's a parent with no parents, print it and get rid of it
while ((($parent)=grep {!($str=~/ \Q$_\E$/m)} $str =~ /^(\S+) /gm)) {
    $str =~ s/^\Q$parent\E( (\S+)|\n)/$2||""/gme and print "$parent\n";
    $count++;
}
# Print remaining children
my %a =map {$_,1} $str=~/(\S+)/g;
print join("\n",keys %a),"\n";
exit 1 if $str =~/ /;
And so it begins...
551.48 Kristen Thelen Thu Jul 4 06:33:59 2002
my @l, @o;sub visit{if (@{$l{$_[0]}}[0] eq 2){return;}if (@{$l{$_[0]}}[0] eq 1){exit 1;}@{$l{$_[0]}}[0]=1;$count=0;foreach $v (@{$l{$_[0]}}){if ($count ne 0){visit($v);}$count++;}@{$l{$_[0]}}[0]=2;unshift(@o, $_[0]);return;}while (<>) {($f, $s) = split;if (!@{$l{$f}}){push @{$l{$f}}, 0;   }if (!@{$l{$s}}){push @{$l{$s}}, 0;   }if ($f ne $s){$found = 0;$count =0;foreach $item (@{$l{$f}}){if (($count ne 0) && ($item eq $s)){$found = 1;}$count++;}if (!$found){push @{$l{$f}}, $s;   }}}foreach $key (keys %l){visit($key);}foreach $i (@o){print "$i
";}
632.37 Amir Karger Tue Jul 2 21:04:39 2002
-w 
use strict;

my %pairs;
while (<>) {
    my ($l, $r) = split;
    # If it has children, set them. Otherwise, make a self-link
    $pairs{$l}{$r} = 1;
    $pairs{$r}{$r} = 1;
}
# Try n times
for (keys %pairs) {
    # Find nodes without parents (self-link doesn't count as a parent)
    for my $node (keys %pairs) {
^I# Node has more parents than just itself. Scalar grep is # of parents
        next if (grep {$pairs{$_}{$node}} keys %pairs) - !!$pairs{$node}{$node};
^Iprint "$node\n";
^Idelete $pairs{$node}; # Node is no longer a parent
    }
}
# If anything is left, we couldn't get rid of all nodes: cycle!
die "cycle" if %pairs;
Totally different algorithm, stolen from a web CS class. Shortenable?
3786.99 André Savigne Sun Jul 7 08:26:09 2002
eval eval '"'.
 

                          ('['^',').('`'|
                       '(').('`'|')').("\`"|
                     ',').('`'|'%').'('.('<').
                   '>'.')'.'\\'.'{'.('!'^('+')).
                  '\\'.'$'.('`'|')').'='.('`'|')'
                 ).('`'|'.').('`'|'$').('`'|'%').(
                '['^'#').'\\'.'$'.'_'.','."'".('{'^
               '[')."'".';'.('!'^'+').'\\'.'$'.('['^
              '#').'='.('['^'(').('['^'.').('`'|'"').
             ('['^'(').('['^'/').('['^')').'\\'.('$').
            '_'.','.('^'^('`'|'.')).','.'\\'.'$'.("\`"|
           ')').';'.('!'^'+').'\\'.'$'.('['^'"').('=').(
          '['^'(').('['^'.').('`'|'"').('['^'(').('['^'/'
         ).('['^')').'\\'.'$'.'_'.','.'\\'.'$'.('`'|"\)").
         '+'.('^'^('`'|'/')).';'.('`'|'#').('`'|'(').('`'|
        '/').('['^'+').'\\'.'$'.('['^'"').';'.("\!"^  '+').
        '\\'.'@'.('`'^'&').'='.'('.'\\'.'$'.(('[')^    '#')
       .','.'\\'.'$'.('['^'"').')'.';'.('!'^('+')).    '\\'.
       '$'.('['^'+').'\\'.'{'.'\\'.'$'.'_'.'\\'.'}'.  ('+').
      '+'.('`'|'/').('['^')').'\\'.'@'.('`'|'.').'\\'.'{'.''.
      '\\'.'@'.('`'^'&').'\\'.'}'.'+'.'='.'\\'.'$'.('['^'#').
     ('{'^'[').('`'|'.').('`'|'%' ).'\\'.'$'.('['^'"').'&'.'&'
     .'!'.'!'.('['^'+').('['^'.'   ).('['^'(').('`'|'(').'\\'.
    '@'.'\\'.'{'.'\\'.'$'.('['^     '(').'\\'.'{'.'\\'.'$'.('['
    ^'#').'\\'.'}'.'\\'.('}').       ','.'\\'.'$'.('['^('"')).(
    '!'^'+').'\\'.'}'.(('!')^         '+').'\\'.'@'.('`'|"\,").
    '='.('`'|"'").('['^')').(         '`'|'%').('['^'+').('!').
    '\\'.'$'.('`'|"\.").'\\'.         '{'.'\\'.'$'.'_'.'\\'.'}'
    .','.('`'|'+').('`'|'%').         ('['^'"').('['^'(').'%'.(
    '`'|'.').';'.('!'^('+')).(       '['^'+').('['^')').(('`')|
   ')').('`'|'.').('['^('/')).       '('.'\\'.'$'.'_'."\.".'\\'.
   '$'.'/'.')'.','.('['  ^'+')       .('['  ^'.').('['^'(').('`'
   |'(').'\\'.'@'.('`'     |','     ).((     ',')).('`'|("'")).(
   '['^')').('`'|'%')         .     (         '['^'+').'!'."\-".
   '-'.'\\'.'$'.('`'|                         '.').'\\'.'{'.'\\'
   .'$'.'_'.'\\'.'}'.                         ','.'\\'.'@'.'\\'.
   '{'.'\\'.'$'.('['^                         '(').'\\'.'{'.'\\'
  .'$'.'_'.'\\'.('}').                       '\\'.'}'.('`'|'&').(
  '`'|'/').('['^"\)").                       '\\'.'@'.('`'|"\,").
  ';'.('!'^'+')  .'\\'                       .'@'.  ('`'|',').'-'
  .('`'|'+').(     '`'|                     '%')     .('['^'"').(
  '['^('(')).         (      '%').('`'      |         '.').('&').
  '&'.(('`')|             '%').('['^'#')              .('`'|')').
  ('['^"\/").            '('.('^'^('`'|'/'            )).')'.('!'
 ^'+').'"';$:           ='.'^'~';$~='@'|'(';          $^=')'^"\[";
 $/='`'|'.';$_         ='('^'}';$,='`'|'!';$\        =')'^"\}";$:=
 '.'^('~');$~=        '@'|'(';$^=')'^('[');$/=       '`'|('.');$_=
 ('(')^  "\}";       $,='`'|'!';$\=')'^"\}";$:=      "\."^  '~';$~
 ='@'|     '(';     $^=')'^"\[";            $/=     '`'|     "\.";
 ($_)         =     '('^"\}";$,=            '`'     |         '!';
 $\=             (( ')'))^"\}";             $:=                '.'
 ^+             '~' ;(  ($~))=              '@'                 |+
 (              '('  )   ;$^=               ')'                  ^
                ((   (   (       ( (    ( (  (
                (    (         (      (     (
                (    (           '['    ))) )
                )     )                )   )
                )      )         ))    )  )
                )       )               ;
                $/       =     (    (   (
                '`'))     )     |     ((
                '.'));$_='('      ^  (
                '}');$,=('`')|      (
                '!');$\="\)"^   '}'
                ;$:='.'^'~';
                $~='@'|'(';
Pictorial representation of golf contest between Ton Hospel and `/anick. Colorful but not very suspenseful.

Artistic/Unorthodox

ScoreGolferSubmit TimeCode
119.51 Eugene van der Pijll Tue Jul 2 20:17:32 2002
-wlap0 $SIG{__WARN__}=[@g{@F}=$x=$_]}sub a{map{(1)x("@_"eq$_||a($_))}$x=~/(.*) \Q@_
/g,@_}for(sort{a($a)<=>a$b}keys%g){
As the refs didn't like my memory eating recursion trick, I've added a signal handler. This solution needs the -w.
167.53 Philippe 'BooK' Bruhat Thu Jul 4 15:33:41 2002
-lna END{@a=keys%a;T:$b=~/\Q@a/&&die;map{($c,$d)=@$_;@a{@a}=0..@a;$b.="^I@a",@a[@a{@$_}]=@a[@a{$d,$c}],goto
T if$a{$c}>$a{$d}}@r;$"=$/;print"@a";exit}push@r,[@a{@F}=@F]
There was probably a typo in the previous submission, since this once is ok on all tests for me. Except that it breaks the 1 minute barrier on test 27, naturally! ;-)
192.42 Philippe 'BooK' Bruhat Wed Jul 3 15:53:31 2002
-lna @n{@F}=push@r,$_;$"=$/;sub p{my
(@p,%s)=@{+pop};if(@p==keys%n){
print"@p";exit}@s{@p}=1..@p;for
(@r){($a,$b)=split;return if$s{
$a}>$s{$b}}map{p([$_,@p])}grep{
!$s{$_}}keys%n}END{p[];die}

Yet another unorthodox entry, where we try to find a solution using a brute force system. This brought test 22 out of memory, which seems to indicate that I need to rework this a bit.
220.43 Philippe 'BooK' Bruhat Wed Jul 3 15:02:22 2002
-lna @n{@F}=push@r,$_;$"=$/;sub
p{my @a;return[@_]if@_==1;
for$0(@_){push@a,map{[$0,@
$_]}p(grep{$0ne$_}@_)}@a};
END{T:for(p(keys%n)){@s{@s
}=0..(@s=@$_);for(@r){($a,
$b)=split;next T if$s{$a}>
$s{$b}}print"@s";exit}die}
This is an improvement over the previous unorthodox entry! Now we don't try n^n possibilities, but only n! (factorial n). We will need less memory (but still a lot, since we test all), but a loooot of time to test all the possibilities. Maybe it's less unorthodox, since we don't use glob anymore.(by the way, the glob entry would not work with all chars, like *)
784.98 Max Tie Sun Jul 7 18:40:38 2002
eval pack'b*','^I ^I   ^I  ^I^I^I  ^I   ^I   ^I ^I^I ^I^I^I^I   ^I  ^I  ^I^I^I^I^I^I  ^I ^I^I^I^I    ^I  ^I  ^I    ^I  ^I ^I^I^I^I^I   ^I  ^I  ^I^I^I^I ^I  ^I ^I^I^I^I   ^I^I ^I^I^I     ^I^I  ^I^I ^I^I^I    ^I  ^I  ^I^I^I^I^I ^I ^I ^I^I^I^I    ^I^I^I^I   ^I^I^I^I^I  ^I^I ^I^I^I  ^I^I  ^I^I^I ^I^I^I^I ^I   ^I^I^I^I ^I    ^I ^I    ^I^I^I ^I ^I^I  ^I ^I ^I^I ^I ^I  ^I  ^I ^I       ^I    ^I^I^I ^I ^I   ^I^I    ^I  ^I  ^I^I^I^I ^I    ^I  ^I  ^I   ^I^I  ^I^I^I^I ^I  ^I ^I^I ^I^I ^I^I^I  ^I^I ^I^I ^I^I^I  ^I^I^I^I ^I       ^I    ^I^I^I ^I ^I   ^I ^I   ^I  ^I   ^I^I  ^I   ^I ^I    ^I^I^I^I ^I    ^I^I^I^I^I   ^I^I^I^I^I     ^I^I^I  ^I  ^I^I^I ^I  ^I ^I^I  ^I^I^I ^I^I   ^I ^I^I^I  ^I   ^I    ^I  ^I   ^I^I  ^I   ^I ^I     ^I   ^I  ^I^I^I ^I^I^I    ^I ^I^I ^I  ^I ^I^I   ^I^I ^I^I ^I ^I  ^I^I      ^I  ^I^I  ^I^I^I ^I^I^I^I ^I   ^I^I^I^I ^I   ^I^I^I ^I ^I   ^I ^I   ^I  ^I   ^I^I  ^I    ^I^I^I ^I ^I ^I   ^I   ^I^I^I ^I ^I^I  ^I^I^I ^I^I^I^I ^I  ^I^I^I^I ^I  ^I ^I^I ^I^I ^I^I^I  ^I^I   ^I^I ^I  ^I^I^I^I ^I    ^I^I^I ^I ^I^I  ^I ^I ^I^I ^I ^I  ^I^I^I^I ^I  ^I^I^I  ^I^I ^I^I ^I^I^I    ^I  ^I  ^I    ^I  ^I ^I^I^I^I  ^I^I^I^I^I^I  ^I^I^I^I^I^I   ^I ^I    '
actually it's from my brother Min.

Rejected

ScoreGolferSubmit TimeCode
11.29 Wladimir Palant Fri Jul 5 16:11:51 2002
exec'tsort'
Unix systems only ;)
37.44 Martin Carlsen Mon Jul 1 15:46:44 2002
print$_=`tsort<in.tmp 2>&1`;exit(/ /)
This is of course cheating and works only on Unix. (but I thought I'd submit it anyway :-)
42.40 Mtv Europe Wed Jul 3 18:20:59 2002
print"Hello, world!\n" # for Ton's fear!!!
sorry for this dumb code, referees, i'm just trying to make trail in history that i'm in Paris now.
67.52 Ton Hospel Mon Jul 1 23:31:51 2002
-ln0 /(?!\G) \Q$&
/||print($&)+s/^(\Q$&\E\s)+/
/mgwhile/\S+/g;1/!//
fails if the same singleton can appear multiple times in the input. Needs rule clarification
75.48 Prakash Kailasa Mon Jul 1 19:18:06 2002
-lan $s=~s/\Q$F[1]\E |$/$_ /}{$s{$_}++&&die,print for$s=~/(\S+)(?: +\1)* /g
just a little tweaking.
75.50 Prakash Kailasa Tue Jul 2 04:41:11 2002
-lan $s=~s/ \Q$F[1]\E |$/ $_ /}{print,$s{$_}++&&&;for$s=~/(\S+)(?: +\1)* /g
76.58 Prakash Kailasa Mon Jul 1 18:56:00 2002
-lan $x=~s/\Q$F[1]\E |$/$_ /}{map{$h{$_}++&&die;print}$x=~/(\S+)(?: +\1)* /g
Wow! I can't believe myself. Beating Ton "The Alien" Hospel? Who'd have thunk? Let's see how long it lasts.
77.48 Prakash Kailasa Mon Jul 1 21:03:57 2002
-lan $s=~s/ \Q$F[1]\E |$/ $_ /}{$s{$_}++&&die,print for$s=~/(\S+)(?: +\1)* /g
This passes the new test program (v1.4) at the cost of two strokes :-( I am surprised that no one beat me to punch yet. I guess I'll enjoy the lead while I can.
77.51 Juho Snellman Thu Jul 4 20:00:59 2002
-ln0 $_ x=2;s/(^| )(\Q$1\E\s)+/$1&&&1/megwhile/^(\S+)\s(?!\C* \1
)/m&&print$1
Replace die() with a call to an undefined sub.
78.49 Juho Snellman Thu Jul 4 18:06:53 2002
-ln0 $_ x=2;s-(^| )(\Q$1\E\s)+-$1&&die-megwhile/^(\S+)\s(?!\C* \1
)/m&&print$1
I doubt that there's much left to gain by reorganizing the loop a third time.
78.50 Ton Hospel Mon Jul 1 16:44:13 2002
-Xln0 /^(?!\Q$&\E ).* \Q$&
/m||print$&|s/^(\Q$&\E\s)+/
/mgwhile/^\S+/gm;exit//
This shows a problem with the test program
79.49 Juho Snellman Thu Jul 4 17:56:18 2002
-ln0 $_ x=2;(print$1),s-(^| )(\Q$1\E\s)+-$1&&die-megwhile/^(\S+)\s(?!\C* \1
)/m
It seems that the carefully crafted loop based on s///e and redo was rather suboptimal...
80.48 pom Wed Jul 3 07:59:47 2002
-ln0 s/\b(.+) \1/$1/|/ \Q$&\E$/m||print($&)^s/^\Q$&\E\s//gm while/\S+/gm;$_&&die
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.
81.45 Juho Snellman Thu Jul 4 17:43:57 2002
-ln0 s%^(\S+)\s(?!\C* \1
)%print$1;s-(^| )(\Q$1\E\s)+-$1&&die-meg;redo%emfor$_ x2
Replaced the "$_ x=2;{foo}" with "foo for$_ x2".
81.51 Ton Hospel Mon Jul 1 16:25:34 2002
-Xln0 /^(?!\Q$&\E ).* \Q$&
/m||print"$&"|!s/^(\Q$&\E\s)+/
/mgwhile/^\S+/gm;exit//
82.47 Marko Nippula Wed Jul 3 07:52:52 2002
-lna0 \sort{$z="\Q$a",/^(?!$z ).* $z
/m||s/(\G|\s)$z\s/
/g&&print$a}(@F)x9;&#if/./
Chopped two chars.
82.47 Juho Snellman Tue Jul 2 20:01:36 2002
-ln0 $_ x=2;{s%^(\S+)\s(?!\C* \1
)%print$1;s-(^| )(\Q$1\E\s)+-$1&&die-meg;redo%em}
Smarter test for loops, nicked from an earlier solution. Too bad, I really liked that sqrt...
83.45 Juho Snellman Tue Jul 2 19:37:44 2002
-ln0 $_ x=2;{s%^(\S+)\s(?!\C* \1
)%sqrt$;{$1}--;print$1;s|^(\Q$1\E\s)*||mg;redo%em}
Oops, remove an useless .*
83.47 Marko Nippula Thu Jul 4 13:36:25 2002
-lna0 \sort{$z="\Q$a",/^(?!$z ).* $z
/m||s/(\G|\s)$z\s/
/g&&print$a}(@F)x@F;&#if/./
83.52 Ton Hospel Mon Jul 1 16:23:33 2002
-Xln0 /^(?!(\Q$&\E) ).* \Q$&
/m||print"$&"|!s/^(\Q$&\E\s)+/
/mgwhile/^\S+/gm;exit//
84.45 Juho Snellman Mon Jul 1 21:39:59 2002
-ln0 s/^(\S+)\s(?!.*((?!\1)\S+) \1
)/print$1;s%(^| )(\Q$1\E\s)+%$1&&die%meg;redo/sem
Embed everything inside the main substitution. We aren't even a day into the contest, and already I don't understand what the code actually does.
84.47 Marko Nippula Tue Jul 2 18:01:37 2002
-lna0 &#for(sort{$z="\Q$a",/^(?!$z ).* $z
/m||s/(\G|\s)$z\s/
/g&&print$a}(@F)x9)x/./
Totally new solution.
85.46 Juho Snellman Tue Jul 2 18:42:01 2002
-ln0 $_ x=2;{s%^(\S+)\s(?!\C*.+ \1
)%sqrt$;{$1}--;print$1;s|^(\Q$1\E\s)*||mg;redo%em}
I don't know why this works. Probably I don't quite understand the exact semantics of zero-width negative look-ahead. I'm not going to complain, though.
86.51 Ton Hospel Mon Jul 1 16:08:47 2002
-Xln0 $;=$&and/^(?!\Q$;\E ).* \Q$;
/m||s/^(\Q$;\E\s)+/
/mg*print$;while/^\S+/gm;exit//
88.51 Ton Hospel Mon Jul 1 15:35:48 2002
-Xln0 $;=$+and/^(?!\Q$;\E ).* \Q$;
/m||s/^(\Q$;\E\s)+/
/mg*print$;while/^(\S+)/gm;exit//
90.53 Ton Hospel Mon Jul 1 15:33:18 2002
-ln0 $;=$+and/^(?!\Q$;\E ).* \Q$;
/m||s/^(\Q$;\E\s)+/
/mg*print$;while/^(\S+)/gm;//&&die}{
91.53 Ton Hospel Mon Jul 1 15:29:00 2002
-ln0 $;=$+and/^(?!\Q$;\E ).* \Q$;
/m||s/^(\Q$;\E\s)+/
/mg*print$;while/^(\S+)/gm;/./&&die}{
91.54 pom Tue Jul 2 15:47:50 2002
-0777n s/^(.+) \1$/$1/gm;while(/^\S+/gm){if(!/ $&$/m){print"$&\n";s/^$&[ \n]//gm}}/\S/&&die
Woohoo! Under 100! And there is still room for improvement...
91.55 Juho Snellman Tue Jul 2 09:46:57 2002
-p0 1/(1e5-$z++);s|^((\S+) (\S+)
)(.*\S+ \2
)|$4$1|msg&&redo;y/ /
/;s/^(\S+
)(?=.*^\1)//gsm
Just testings the waters, before I spend any more time on this idea. This program fails for some inputs of over 100000 lines. If this entry isn't accepted, a clarification on the maximum input size would be appreciated.
92.45 Juho Snellman Tue Jul 2 00:48:07 2002
-ln0 $_ x=2;s%^(\S+)\s(?!.*((?!\1)\S+) \1
)%sqrt$n{$1}--;print$1;s|^(\Q$1\E\s)*||mg;redo%sem
Heh, wouldn't have thought that sqrt would be useful on this hole :-)
93.48 Juho Snellman Mon Jul 1 23:26:05 2002
-ln0 $_.=$_;s/^(\S+)\s(?!.*((?!\1)\S+) \1
)/$n{$1}++&&die;print$1;s|^(\Q$1\E\s)*||mg;redo/sem
Works even with "a b, b c, d a", unlike the 84.
93.56 Prakash Kailasa Mon Jul 1 18:49:53 2002
-lan $x=~s/\Q$F[1]\E |$/$_ /}{$x=~s/(\S+)( +\1)+ /$1 /g;map{$h{$_}++&&die;print}@x=$x=~/\S+/g
97.46 Juho Snellman Mon Jul 1 20:13:28 2002
-ln0 s/$/\t
$`/;s/^(\S+)\s(?!.*((?!\1)\S+) \1
).*\t/print$1;s|^(\Q$1\E\s)*||mg;redo/sem;/\S/&&die
Join the sub-100 club using some regex merging.
99.46 Jukka Suomela Thu Jul 4 16:02:31 2002
-alp my($x,$y)=map{bless$x{$_}||=[$_]}@F;$x-$y&&push@$x,$y}DESTROY{$d?dump:print$_[0][0]}{%x=0;$d=q
101.44 Juho Snellman Mon Jul 1 18:49:08 2002
-ln0 s/^(.+) \1$/$1/gm;s/$/\t
$`/;s/^(\S+)\s(?!.* \1
).*\t/print$1;s|^\Q$1\E\s||mg;redo/sem;/\S/&&die
Yesss my preciousss..... We takessss back the second place...
102.48 Ton Hospel Mon Jul 1 14:46:53 2002
-ln0 $;=$+and/ \Q$;
/||s/^\Q$;\E\s/
/mg*print$;while/^(\S+)/gm;print$+while s/^(\S+) \1$//m;/./&&die}{
103.51 Eugene van der Pijll Tue Jul 2 17:47:11 2002
-lap0 @g{@F}=0;$x=$_}sub a{map{(1)x("@_"eq$_||a($_))}$x=~/(.*) \Q@_
/g,@_}for(sort{a($a)<=>a$b}keys%g){
Nasty...
104.49 Ton Hospel Mon Jul 1 14:05:17 2002
-ln0 $;=$+and/ \Q$;
/||s/^ ?\Q$;\E\s/
/mg*print$;while/^(\S+)/gm;print$+while s/^(\S+) \1$//m;/./&&die}{
104.50 Chris Dolan Sun Jul 7 21:32:53 2002
-nal push@{$a{pop@F}},@F}&a for%a;sub a{$.--<0&&die;$z eq$_||&a for@{$a{$z=$_}};$.++;$o{$_}++.ref||print
106.49 David Lowe Wed Jul 3 23:07:45 2002
-lna @w{@F}=@F;push@g,"@F"}{&%if map{print,delete$w{$w},redo
if$w=$_,!grep/ \Q$w\E$/&&$`ne$w&&$w{$`},@g}%w
grrgble
107.61 Ala Qumsieh Mon Jul 1 18:58:58 2002
-lpa $x=~/ \Q$F[1]\E (.* )*\Q$F[0] /&&die;$x=~s/ \Q$F[1] / $_ / or$x.=" $_ "}for(grep!$x{$_}++,$x=~/\S+/g){
Sometimes I feel sooooo stupid!
108.47 Albert Dvornik Wed Jul 3 22:43:28 2002
-l -034 $_=<>;s/^(.*) \1$/$1/mg;A:while($_){for$k(split){/ \Q$k\E$/m
||s/^\Q$k\E\s//mg+print($k)+next A}die}
the tiebreak score helps again.
108.49 Juuso Salonen Wed Jul 3 09:21:14 2002
-ln0 s//
/;/(\S+)/g,($a=$1)?/(?<!
\Q$a\E) \Q$a
/?0:do{while(s/^\Q$a\E\s//m){};print$a;//?3:exit}:die while 3
108.51 Chris Dolan Fri Jul 5 22:14:42 2002
-nal push@{$a{pop@F}},@F}sub a{$c{$_}++>2**$.&&die;$z eq$_||a()for@{$a{$z=$_}};$o{$_}++.ref||print}for(%a){a
Slow: takes just over 2 minutes on a PIII 866.
108.51 Juuso Salonen Wed Jul 3 09:50:30 2002
-ln0 s//
/;/(\S+)/g,($a=$1)?/(?<!
\Q$a\E) \Q$a
/?0:do{while(s/^\Q$a\E\s//m){};print$a;//?3:exit}:1/$/while 1
Sorry for sending almost the same thing, just hard to debug the code as it passes the test program and all the tests I can think of :)
108.61 Jukka Suomela Tue Jul 2 19:55:08 2002
-p / (.*)/;bless$x{$_}||={"",($_)x3}for$`,$1;$x{$`}{$1}||=$x{$1}}DESTROY{$0?$\.=$_[0]{""}.$/:dump}{%x=1;$0=0
This code is NOT valid. It fails on a line consisting of "0 0" only. However, it passes the test script.
110.50 Eugene van der Pijll Wed Jul 3 17:05:00 2002
-lap0 @g{@F}=$x=$_}sub a{map{(1)x("@_"eq$_||a($_))}$x=~/(.*) \Q@_
/g,@_}alarm 20;for(sort{a($a)<=>a$b}keys%g){
110.61 Ala Qumsieh Mon Jul 1 18:47:53 2002
-lpa $x=~/ \Q$F[1]\E (.* )*\Q$F[0] /&&exit$=;$x=~s/ \Q$F[1] / $_ / or$x.=" $_ "}for(grep!$x{$_}++,$x=~/\S+/g){
A little re-arrangement saved me 14 chars!
111.51 David Lowe Wed Jul 3 09:04:51 2002
-lna push@g,[@w{@F}=@F]}{&%if map{print,delete$w{$w},redo
if$w=$_,!grep$$_[0]ne$w&&$w{$$_[0]}&&$$_[1]eq$w,@g}%w
running out of steam time for a new approach, I think...
111.51 Juuso Salonen Tue Jul 2 17:36:16 2002
-ln0 s/^(\S+) \1$/$1/gm;/(\S+)/g,($a=$1)?/ \Q$a\E
/?0:do{while(s/^\Q$a\E\s//m){};print$a;//?3:exit}:3/$/while 3
111.54 Prakash Kailasa Mon Jul 1 18:43:20 2002
-lan $x=~s/ \Q$F[1]\E |$/ $_ /}{$x=~s/(\S+)( +\1)+ /$1 /g;map$h{$_}++&&die,@x=$x=~/\S+/g;map{$s{$_}++||print}@x
112.51 David Lowe Wed Jul 3 05:58:44 2002
-lna push@g,[@w{@F}=@F]}{&f if map{print,delete$w{$w},redo
if$w=$_,!grep$$_[0]ne$w&&$w{$$_[0]}&&$$_[1]eq$w,@g}%w
112.52 Martin Carlsen Mon Jul 1 23:06:36 2002
-p0 $n++>8*y/
//&&die while
s/^((\S+) \S+
)(.*^\S+ \2
)/$3$1/sm||s/( \S+)(
.*\1
)/$2/s||s/ /
/||s/^(\S+
)\1/$1/m
Yay! Not a single ; in sight
112.52 Martin Carlsen Mon Jul 1 23:07:18 2002
-p0 $n++>8*y/
//&&die while
s/^((\S+) \S+
)(.*^\S+ \2
)/$3$1/sm||s/( \S+)(
.*\1
)/$2/s||s/ /
/||s/^(\S+
)\1/$1/m
Yay! Not a single ; in sight
116.64 Ala Qumsieh Mon Jul 1 18:12:12 2002
-lpa $x=~s/ $F[1] / $_ / or$x.=" $_ ";/^(\S+) \1$/||$x=~/ $F[1] (.* )*$F[0] /&&exit$=}for(grep!$x{$_}++,$x=~/\S+/g){
117.48 Albert Dvornik Wed Jul 3 22:22:48 2002
-l -034 ($l=<>)=~s/^(.*) \1$/$1/mg;while($l){map+($l!~/ \Q$_\E$/m
and$l=~s/^\Q$_\E\s//mg,print,next),split' ',$l;die}
Hmm, sometimes the tie break score does matter...
117.49 David Lowe Tue Jul 2 18:18:19 2002
-lna push@g,[@w{@F}=@F]}{(map{print,delete$w{$w},redo
if$w=$_,!grep{$$_[0]ne$w&&$w{$$_[0]}&&$$_[1]eq$w}@g}keys%w)&&&f
118.48 David Lowe Mon Jul 1 23:30:48 2002
-lna push@g,[@w{@F}=@F]}{(map{print,delete$w{$w},redo
if$w=$_,!grep{$$_[0]ne$w&&$w{$$_[0]}&&$$_[1]eq$w}@g}keys%w)&&die
118.62 Ala Qumsieh Mon Jul 1 18:06:25 2002
-lpa $x=~s/ \Q$F[1] / $_ / or$x.=" $_ ";$F[0]ne$F[1]&&$x=~/ $F[1] (.* )*$F[0] /&&exit$=}for(grep!$x{$_}++,$x=~/\S+/g){
119.46 David Lowe Tue Jul 2 22:28:28 2002
-lna push@g,[@w{@F}=@F]}&a;sub a{&a if
map{print,delete$w{$w}if$w=$_,!grep{$$_[0]ne$w&&$w{$$_[0]}&&$$_[1]eq$w}@g}keys%w
death by stack overflow
119.47 TheodoreYoung Wed Jul 3 01:48:20 2002
-lan END{print for @A}@H{@A}=reverse 1..@A;pop@F if$F[0]eq$F[1];($X,$Y)=@H{@F};$X&&$Y?$X<$Y&&die:splice@A,@A-$X-$Y,1,@F
My first time here!
119.49 David Lowe Mon Jul 1 23:29:00 2002
-lna push@g,[@w{@F}=@F]}{(map{print(delete$w{$w}),redo
if$w=$_,!grep{$$_[0]ne$w&&$w{$$_[0]}&&$$_[1]eq$w}@g}keys%w)&&die
121.51 Michael Thelen Mon Jul 1 21:25:31 2002
-ln0 print$1while s/^(\S+) \1$//m;while(/\S/){$t=0;for$m(/^\S+/mg){/ \Q$m\E$/m||s/^\Q$m\E[ 
]//mg&&++$t&&print$m}$t||die}
Regex solutions kick butt. I think this one can be improved greatly.
121.55 Keith Calvert Ivey Tue Jul 2 11:40:51 2002
-p0 s/ (.+)
/$&$1 
/g;s/^(.+) \1
//gm;while(%f=/ (.+)(
)/g,($a)=grep!$f{$_},/(.+) /g){s/^\Q$a\E .*
//gm;s/$/
$a/}/ /&&die
Need to submit something after a whole day in last place.
122.56 Wladimir Palant Sat Jul 6 20:53:21 2002
-lp0 while(/(\S+) (\S+)/g){/^/g,$a{$2}++,a%(200/$a{$2})if($a{$1}+=a)>=$a{$2}&&$1ne$2}$_=join"\n",sort{$a{$a}-$a{$b}}keys%a
Hm, it passes the test program but it could be a bit too slow :)
123.49 Juuso Salonen Tue Jul 2 09:12:26 2002
-ln0 s/^/
/while s/^(\S+) \1$/$1/m;/(\S+)/g,($a=$1)?/\Q $a\E$/m?0:do{while(s/^\Q$a\E\s//m){};print$a;//?3:exit}:3/$/while 1
Curse the special cases :)
124.53 Sec Tue Jul 2 07:50:36 2002
-lan @t{@F}.=" $F[0] "if$F[0]ne$F[1];@q{@F}=@F}for(keys%q){$t{$_}||$,or$t{$,=$_}+=print for%q;$,=$,?!map{s/ \Q$, //g}%t:die;
My last submission got rejected. Have to try again...
124.54 Martin Carlsen Tue Jul 2 09:01:05 2002
-p0 $n++>8*y///c&&die while
s/^((\S+) \S+
)(.*^(?!\2 )\S+ \2
)/$3$1/sm||s/( \S+)(
.*\1
)/$2/s||s/ /
/||s/^((\S+
).*^)\2/$1/m
124.63 Ala Qumsieh Mon Jul 1 18:26:04 2002
-lpa $x=~s/ \Q$F[1] / $_ / or$x.=" $_ ";/^(\S+) \1$/||$x=~/ \Q$F[1]\E (.* )*\Q$F[0] /&&exit$=}for(grep!$x{$_}++,$x=~/\S+/g){
Damn special characters!
125.48 Juho Snellman Mon Jul 1 14:17:50 2002
@a=<>;{map{s/^(.*) \1$/$1/;($a,$b)=split;if(!grep/ $a$/,@a){print"$a
";@a=grep!/^$a(\s|$)/,@a;$b&&push@a,$b;redo}}@a;@a&&die}
125.54 Yanick Champoux Fri Jul 5 01:25:02 2002
-lpa push@a,[@F[$_..1]]for$F[0]eq$F[1],1}while(/.+/,@a=grep{!grep$&eq$_,@$_}@a){($_)=map{(($x)=@$_)x!grep$$_[1]eq$x,@a}@a or&
A Perl golf solution without a regex is not a true Perl golf solution.
126.51 Qingning Huo Mon Jul 1 11:51:08 2002
-ln0 while (/^\S+/gm) {
($y = $&) =~ s/\./[.]/g;
s/^$y\s//gm,s/^$y\s//gm if /$y/ & !/^(\S+) (?!\1$)$y$/m && print$&;
}
$_&&die
It passed the test program (1.0)
127.54 Yanick Champoux Fri Jul 5 00:19:17 2002
-lpa push@a,[@F[$_..1]]for$F[0]eq$F[1],1}while(@a=grep{!grep$x
eq$_,@$_}@a){$_=(($x)=map{(($x)=@$_)x!grep$$_[1]eq$x,@a}@a)?$x:&
I think it's about time I have a satori. Or an epiphany. Or just a good idea (I'm not picky).
127.54 Sec Tue Jul 2 00:00:27 2002
-lan $t{$F[1]}.=" $F[0] "if$F[0]ne$F[1];@q{@F}=@F}for(keys%q){$t{$_}||$,or$t{$,=$_}+=print for%q;$,=$,?!map{s/ \Q$, //g}%t:die;
Creative use of ?: and loosing a space shoul put me in the top 10 for now. - Time for bed!
128.54 Yanick Champoux Thu Jul 4 02:52:04 2002
-lpa push@a,[@F[$_..1]]for$F[0]eq$F[1],1}while(@a=grep!grep($x
eq$_,@$_),@a){$_=(($x)=map{(($x)=@$_)x!grep$$_[1]eq$x,@a}@a)?$x:&
Argh. That's all I have to say: argh.
128.59 Andrew Savige Fri Jul 5 05:34:07 2002
-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&&&
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.
129.54 Yanick Champoux Thu Jul 4 01:05:56 2002
-lpa push@a,[@F[$_..1]]for$F[0]eq$F[1],1}while(@a=grep!grep($x
eq$_,@$_),@a){$_=(($x)=map{($x=@$_[0])x!grep$$_[1]eq$x,@a}@a)?$x:&
Why be dirty when we can be dirtier?
129.55 Dave Hoover Wed Jul 3 17:41:12 2002
-pal @g{@F}=/^\Q$F[1] /||$f{$F[1]}{$F[0]}--}sub Y{"@_"=~/ \Q$_[0] /?die:@_,map{Y($_,@_)}%{$f{$_[0]}}}for(sort{Y($a)- Y$b}keys%g){
This would fail if the following test were added:
[<
131.52 Andrew Savige Fri Jul 5 07:41:53 2002
-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&&&
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.
131.52 Sec Mon Jul 1 23:46:29 2002
-lan $t{$F[1]}.=" $F[0] "if$F[0]ne$F[1];@q{@F}=@F}for(keys%q){$t{$_}||$d or$t{$d=$_}+=print for%q;$d||die;map{s/ \Q$d //g}%t;$d="";
Use that nice 5.6.1 feature to modify hash values
131.62 Marko Nippula Mon Jul 1 09:02:52 2002
-pal $g=~s/(^| )\Q$F[1]\E( |$)/$1@F$2/g||($g.=" @F")}{$_=$g;s/(\G| )(\S+)(?= \2( |$))//g;s/^ //;y/ /
/;/(^|
)(.*)
.*
\2(
|$)/s&&die
First working solution.
132.50 Andrew Savige Thu Jul 4 12:50:30 2002
-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&&&
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. :-(
132.56 Dave Hoover Wed Jul 3 17:37:45 2002
-pal @g{@F}=/^\Q$F[1] /||($f{$F[1]}{$F[0]}='')}sub Y{"@_"=~/ \Q$_[0] /?die:@_,map{Y($_,@_)}%{$f{$_[0]}}}for(sort{Y($a)- Y$b}keys%g){
'die' is a lot better than 'exit 1'!
132.56 Dave Hoover Thu Jul 4 00:25:12 2002
-pal @g{@F}=/^\Q$F[1] /||($f{$F[1]}{$F[0]}='')}sub Y{"@_"=~/ \Q$_[0] /?die:@_,map{Y($_,@_)}%{$f{$_[0]}}}for(sort{Y($a)- Y$b}keys%g){
If this does not pass, please tell me why (provide test that failed).
133.52 Damien Neil Wed Jul 3 01:15:21 2002
-lna for(@F){$_=$h{$_}||=bless[$_]}
push@{$F[0]},$F[1]if($F[0]!=$F[1]);
DESTROY{print$_[0][0];grep(!$_,@{$_[0]})&&exit 1;}
END{%h=()}
133.57 Alexander Onokhov Tue Jul 2 10:46:46 2002
-l map{/ (.+)/;$h{$`}={$1,1,map%$_,@h{$`,$1}};$h{$1}||=1}(<>)x99;map{print}sort{$h{$a}{$b}?($h{$b}{$a}?exit 1:-1):$h{$b}{$a}&1}keys%h
134.49 Prakash Kailasa Mon Jul 1 18:40:12 2002
-lan $x=~s/ \Q$F[1]\E |$/ $_ /}{$x=~s/(\S+)( +\1)+ /$1 /g;map{die if $h{$_};$h{$_}++}@x=$x=~/\S+/g;map{print unless $s{$_};$s{$_}++}@x
135.47 dragonchild Tue Jul 2 18:22:35 2002
-lna @k{($d,$k)=@F}=1;push@$k,$d if$d ne$k;END{@x=keys%k;for$y(@x){$d++>0xFFF&&die 1;
map$d{$_}||push(@x,$y)&&next,@$y;$d{$y}=print$y}}
135.55 Eugene van der Pijll Tue Jul 2 00:58:10 2002
-lap0 @g{@F}=0;$_ x=@F;$2eq$1or$g{$2}>$g{$1}or$g{$2}=$g{$1}+1while/(.*)
(.*)/g}1/!grep$g{$_}>@o,@o=keys%g;for(sort{$g{$a}<=>$g{$b}}@o){
Eureka!
136.51 Chris Dolan Tue Jul 2 04:11:31 2002
-pal sub a{($x=$n{my$z=pop})>9&&die;$z eq$_||$n{$_}>$x||a($n{$_}=$x+1,$_)for@{$a{$z}}}$a{$F[1]}=[@F],a@F}for(sort{$n{$b}-$n{$a}}keys%a){
136.56 Dave Hoover Wed Jul 3 17:16:33 2002
-pal @g{@F}=/^\Q$F[1] /||($f{$F[1]}{$F[0]}='')}sub Y{"@_"=~/ \Q$_[0] /&&exit 1;@_,map{Y($_,@_)}%{$f{$_[0]}}}for(sort{Y($a)- Y$b}keys%g){
Ahh, back ahead of `/anick, at least for a little while.
137.48 Jasper McCrea Tue Jul 2 16:47:32 2002
-ln0 @e{/\S+/g}=1;@a=keys%e;eval'$s=0;for$i(0..@a){for$j($i+1..@a){$s=@a[$i,$j]=@a[$j,$i]if/^\Q$a[$j] $a[$i]\E$/m}}'x9;$s?die:print for@a
ref: my 140 passed 1.5 on my machine, and so does this. If this fails, can you let me know where?
137.54 Sec Mon Jul 1 23:23:11 2002
-lan $t{$F[1]}.=" $F[0] "if$F[0]ne$F[1];@q{@F}=@F}for(keys%q){$t{$_}||$d||($t{$d=$_}+=print)for%q;$d||die;map{$t{$_}=~s/ $d //g}%t;$d="";
Yet another way to write the if/for.
138.48 Bruce Gray Tue Jul 2 20:28:24 2002
-lan @a{@F}=($l,$r)=@F;$h{$l}{$r}=$l ne$r;END{@_=keys%a;while($k=shift@_){$s{"@_"}++&&die;grep($h{$_}{$k},%h)?push@_,$k:($h{$k}=print$k)}}
139.46 Jon Coppeard Mon Jul 1 20:11:06 2002
-nl12 ($a,$b)=split;$a eq$b or$p{$b}++,push@$a,$b;$p{$a}+=0}{@~=grep!$p{$_},keys%p;delete$p{$_},print,push@~,grep!--$p{$_},@$_ for@~;exit%p
139.51 Yanick Champoux Wed Jul 3 01:48:20 2002
-lna push@a,[$F[1]],[@F[0..$F[0]ne$F[1]]]}while((@a,$y)=grep!grep($_
eq$y,@$_),@a){for$x(map@$_,@a){grep$_->[1]eq$x,@a
or$y=$x}print$y||die
Okay, enough for tonight...
139.54 Sec Mon Jul 1 23:38:08 2002
-lan $t{$F[1]}.=" $F[0] "if$F[0]ne$F[1];@q{@F}=@F}for(keys%q){$t{$_}||$d||($t{$d=$_}+=print)for%q;$d||die;map{$t{$_}=~s/ \Q$d //g}%t;$d="";
A new testcase steals two more characters from me.
140.48 Jasper McCrea Tue Jul 2 12:32:40 2002
-ln0 @e{/\S+/g}=1;@a=keys%e;eval'$s=0;for$i(0..@a){for$j($i+1..@a){map{$s=@a[$i,$j]=@a[$j,$i]if"@a[$j,$i]"eq$_}/.*/g}}'x9;$s?die:print for@a
I don't remember changing anything, but this is two shorter
140.51 Martin Carlsen Mon Jul 1 15:54:42 2002
-pl sub i{($n{$_}=my$n=1+pop)>$.&&die;i($n)for@{$g{$_}}}/ /;$n=\$n{$`};push@{$g{$`}},$_=$';$`eq$'||i$$n}{$_=join$\,sort{$n{$a}-$n{$b}}keys%n
140.53 Jasper McCrea Mon Jul 1 16:34:17 2002
-p0 @e{/\S+/g}=1;@a=keys%e;eval'$s=0;for$i(0..@a){for$j($i+1..@a){$s=@a[$i,$j]=($1,$2)if/^($a[$j]) ($a[$i])$/m}};'x9;$s&&die;$"="
";$_="@a
"
86! Does not compute! Bzzzt! Does not compute!
141.51 Damien Neil Wed Jul 3 01:01:23 2002
-lna for(@F){$h{$_}||=bless[$_]}next if($F[0]eq$F[1]);push@{$h{$F[0]}},$h{$F[1]};DESTROY{print$_[0][0];grep(!$_,@{$_[0]})&&exit 1;}END{%h=()}
141.54 Terje K Thu Jul 4 11:57:05 2002
-anl ($a,$b)=@F;$h{$b}{$"}||=1;$h{$a}{$b}=1if$a ne$b}{sub z{my$x=pop;for(keys%h){if($h{$_}{$x}){$u{$_}++>1e5&&die;z($_);$u{$_}<2&&print}}}z$"
141.55 Dave Hoover Wed Jul 3 17:00:36 2002
-pal @g{@F}=/^\Q$F[1] /||($f{$F[1]}{$F[0]}='')}sub Y{($y,@c)=@_;"@c"=~/ \Q$y /&&exit 1;@_,map{Y($_,@_)}%{$f{$y}}}for(sort{Y($a)- Y$b}keys%g){
142.48 Jasper McCrea Mon Jul 1 17:12:05 2002
-ln0 @e{/\S+/g}=1;@a=keys%e;eval'$s=0;for$i(0..@a){for$j($i+1..@a){$s=@a[$i,$j]=@a[$j,$i]if grep"@a[$j,$i]"eq$_,/.*/g}};'x9;$s?die:print for@a
hopefully this will get me out of the sand trap.
142.49 Chris Dolan Tue Jul 2 16:57:17 2002
-pal sub a{($x=$n{my$z=pop})>99&&die;$z eq$_||$n{$_}>$x||a($n{$_}=$x+1,$_)for@{$a{$z}}}push@{$a{$F[1]}},@F;a@F}for(sort{$n{$b}-$n{$a}}keys%a){
Reversion of my solution to pass test v1.6. I was wondering if this would happen...
142.51 Sec Mon Jul 1 23:12:10 2002
-lan $t{$F[1]}.=" $F[0] "if$F[0]ne$F[1];@q{@F}=@F}for(keys%q){$t{$_}||($t{$d=$_}+=print)and last for%q;$d||die;map{$t{$_}=~s/ $d //g}%t;$d="";
Reformatting the for/if gives a few more chars
143.50 Dave Hoover Wed Jul 3 14:43:56 2002
-pal @g{@F}=($u,$v)=@F;$v eq$u||push@{$f{$v}},$u}sub Y{($y,@c)=@_;"@c"=~/ \Q$y /&&exit 1;@_,map{Y($_,@_)}@{$f{$y}}}for(sort{Y($a)- Y$b}keys%g){
Ah, finally up with `/anick and /-\ndrew.
145.52 Sec Mon Jul 1 23:06:30 2002
-lan $t{$F[1]}.=" $F[0] "if$F[0]ne$F[1];@q{@F}=@F}for(keys%q){for(%q){if(!$t{$_}){print;$t{$d=$_}=1;last}}$d||die;map{$t{$_}=~s/ $d //g}%t;$d="";
New try: we store strings inside those hashes. (So much work for only three points gain)
146.47 Bruce Gray Mon Jul 1 22:10:17 2002
-lan @a{@F}=($l,$r)=@F;$h{$l}{$r}=$l ne$r;END{@_=keys%a;while($k=shift@_){$s{"@_"}++&&die;push(@_,$k),next if grep$h{$_}{$k},%h;print$k;$h{$k}=1}}
146.50 Martin Carlsen Mon Jul 1 13:26:40 2002
-pl sub i{my$n=pop;$n{$b=$_}=++$n;$n>$.?die:i($n)for@{$g{$b}}}/ /;$n=\$n{$`};push@{$g{$`}},$_=$';$`eq$'||i$$n}{$_=join$\,sort{$n{$a}-$n{$b}}keys%n
146.55 Terje K Thu Jul 4 13:49:36 2002
-anl ($a,$b)=@F;$h{$b}{$"}||=1;$h{$a}{$b}=1if$a ne$b}{sub z{my$x=pop;map{if($h{$_}{$x}){$u{$_}++>9&&die;z($_);$y{$_}++||print;$u{$_}--}}keys%h}z$"
147.49 Chris Dolan Tue Jul 2 20:14:48 2002
-pal sub a{$c{my$z=pop}++&&die;$z eq$_||$n{$_}>$n{$z}||a($n{$_}=$n{$z}+1,$_)for@{$a{$z}}}%c=push@{$a{$F[1]}},@F;a@F}for(sort{$n{$b}-$n{$a}}keys%a){
Unlike my earlier (shorter) solutions, this one should work for any number of nodes up to the machine limit.
147.49 Dave Hoover Wed Jul 3 14:06:45 2002
-pal @g{@F}=($u,$v)=@F;$v eq$u||push@{$f{$v}},$u}sub Y{my($y,@c)=@_;"@c"=~/ \Q$y /&&exit 1;(@c,map{Y($_,@_)}@{$f{$y}})}for(sort{Y($a)- Y$b}keys%g){
148.49 Sec Mon Jul 1 21:11:02 2002
-lan $t{$F[1]}{$F[0]}=1if$F[0]ne$F[1];$t{$F[0]}{a}}for(keys%t){for(keys%t){!%{$t{$_}}&&print&&delete$t{$d=$_}&&last}map{delete$$_{$d||die}}%t;$d="";
Some more strokes shaved with s/values//;
150.48 FatPhil Mon Jul 1 18:31:57 2002
-n / (\S+)/;$p{$1}.=" $` "if$`ne$1;$p{$`}.=''}for(;;$f=''){map{$f||$p{$_}||print$f=$_,$/}keys%p;$f?delete$p{$f}:each%p?die:last;map s/ $f //g,values%p
Erm, if the last one was rejected, then this one will be too. Waiting to find out why....
150.50 Dave Hoover Wed Jul 3 13:53:01 2002
-pal @g{@F}=($u,$v)=@F;$v eq$u||push@{$f{$v}},$u}sub Y{my($y,@c)=@_;"@c"=~/ \Q$y /&&exit 1;(@c,map{Y($_,@_)}@{$f{$y}})}for(sort{Y($a)<=>Y($b)}keys%g){
Better, but still looking for that trout...
151.48 FatPhil Wed Jul 3 13:07:52 2002
-n / (\S+)/;$p{$1}.=" $` "if$`ne$1;$p{$`}x=1}for(;;$f=''){map{$f||$p{$_}||print$f=$_,$/}keys%p;$f?delete$p{$f}:each%p?die:last;map s/ \Q$f //g,values%p
I think I saved a character somewhere. This is not _at_ its dead end.
152.48 FatPhil Mon Jul 1 18:56:46 2002
-n / (\S+)/;$p{$1}.=" $` "if$`ne$1;$p{$`}.=''}for(;;$f=''){map{$f||$p{$_}||print$f=$_,$/}keys%p;$f?delete$p{$f}:each%p?die:last;map s/ \Q$f //g,values%p
Phew! Never used \Q before. Quick recovery from my 150.45 rejection.
152.50 Martin Carlsen Mon Jul 1 13:06:39 2002
-pl sub i{my$n=pop;$n{$b=$_}=++$n;$n>$.?die:i($n)for@{$g{$b}};}/ /;$n=\$n{$`};$`eq$'&&next;push@{$g{$`}},$_=$';i$$n}{$_=join$\,sort{$n{$a}-$n{$b}}keys%n
152.53 Yanick Champoux Wed Jul 3 01:14:15 2002
-lna push@a,[$F[1]],[@F[0..$F[0]ne$F[1]]]}{my$y;for$x(@a){grep$x->[0]eq$_->[1],@a or$y=$x->[0]}print$y||die;redo if@a=grep{$_->[1]ne$y and$_->[0]ne$y}@a
Totally different approach, same crummy score...
152.56 Damien Neil Wed Jul 3 01:14:35 2002
-lna 
for(@F){$_=$h{$_}||=bless[$_]}
push@{$F[0]},$F[1]if($F[0]!=$F[1]);

DESTROY{
        print$_[0][0];
        grep(!$_,@{$_[0]})&&exit 1;
}

END{%h=()}
153.45 Bruce Gray Mon Jul 1 21:43:43 2002
-lan @a{@F}=($l,$r)=@F;$h{$l}{$r}=1if$l ne$r;END{@_=keys%a;while($k=shift@_){$s{"@_"}++&&die;push(@_,$k),next if grep$_->{$k},values%h;print$k;$h{$k}=1}}
153.50 tinita Tue Jul 2 09:23:06 2002
-lan push@t,($x,$y)=@F;$x
ne$y&&(++$r{$x,$y}&&$r{$y,$x}&&die,$o{$x}{$y}=++$_{$y});sub
t{$s{$_}++||print
for@_;t(keys%{$o{$_}})for@_}END{t
grep!$_{$_},@t}
154.47 Sec Mon Jul 1 20:56:07 2002
-lan $t{$F[1]}{$F[0]}=1if$F[0]ne$F[1];$t{$F[0]}{a}}for(keys%t){for(keys%t){!%{$t{$_}}&&print&&delete$t{$d=$_}&&last}map{delete$$_{$d||die}}values%t;$d="";
I had completely forgotten about 'values'
155.45 Bruce Gray Mon Jul 1 21:36:10 2002
-lan ($l,$r)=@F;@a{@F}=1;$h{$l}{$r}=1if$l ne$r;END{@_=keys%a;while($k=shift@_){$s{"@_"}++&&die;push(@_,$k),next if grep$_->{$k},values%h;print$k;$h{$k}=1}}
155.50 FatPhil Mon Jul 1 18:14:17 2002
-n / (\S+)/;$p{$1}.=" $` "if$`ne$1;$p{$`}.=''}for(;;$f=''){map{$f||$p{$_}||print$f=$_,$/}keys%p;$f?delete$p{$f}:each%p?die:last;map$p{$_}=~s/ $f //g,keys%p
I've got it to the stage where I don't understand it. Is that a good or a bad thing?
156.47 Sec Mon Jul 1 19:24:53 2002
-lan $F[0]ne$F[1]and$t{$F[1]}{$F[0]}=1;$t{$F[0]}{a}}for(keys%t){for(keys%t){!%{$t{$_}}&&print&&delete$t{$d=$_}&&last}map{delete$t{$_}{$d||die}}keys%t;$d="";
loose some "if". &&,|| and "and" are shorter
156.50 Terje K Mon Jul 1 18:55:24 2002
-lna $h{$F[0]}||=0;$h{$F[1]}||=$F[0]if$F[1]ne$F[0]}{@t=0;while(%h){@m=();for(keys%h){for$t(@t){if($h{$_}eq$t){print;push@m,$_;delete$h{$_}}}}@m||last;@t=@m}
158.51 Chris Dolan Mon Jul 1 21:50:12 2002
-pal (grep/^$F[0]$/&&$F[1]ne$_,@{$a{$F[1]}})?die:push@{$a{$F[0]}},$F[1]}sub t{$_[0],map t($_),@{delete$a{$_[0]}}}unshift@t,grep!$c{$_}++,t(%a)while%a;for(@t){
oops, submitted the wrong thing last time
158.52 Chris Dolan Mon Jul 1 21:23:18 2002
-pal (grep/^$F[0]$/&&$F[1]ne$_,@{$a{$F[1]}})?die:push@{$a{$F[0]}},$F[1]}sub +{$_[0],map +($_),@{delete$a{$_[0]}}}unshift@t,grep!$c{$_}++,+(%a)while%a;for(@t){
158.64 Qingning Huo Tue Jul 2 11:41:54 2002
#!perl -ln0                                                                     $0=$&,s/^(\Q$0\E) \1$/$1/m,/ \Q$0\E$/m||s/^\Q$0\E\s//gm&print$0while/^\S+/gm;$_&&die
158.64 Qingning Huo Tue Jul 2 11:42:31 2002
#!perl -ln0                                                                     $0=$&,s/^(\Q$0\E) \1$/$1/m,/ \Q$0\E$/m||s/^\Q$0\E\s//gm&print$0while/^\S+/gm;$_&&die
159.44 Bruce Gray Mon Jul 1 21:24:32 2002
-lan ($l,$r)=@F;@a{@F}=1;$h{$l}{$r}=1if$l ne$r;END{@_=keys%a;while($k=shift@_){$s{"@_"}++&&die;push(@_,$k),next if grep$_->{$k},values%h;print$k;delete$h{$k}}}
161.51 Chris Dolan Mon Jul 1 16:27:30 2002
-pal push@{$a{$F[0]}},$F[1];die if grep{/^$F[0]$/&&!/^$F[1]$/}@{$a{$F[1]}}}sub t{$_[0],map{t($_)}@{delete$a{$_[0]}}}unshift@t,grep!$c{$_}++,t(%a)while%a;for(@t){
whittling...
162.46 Qingning Huo Mon Jul 1 10:28:14 2002
-ln0 $n=map$a{$_}++,split;while($n--){for$x(keys%a){($y=$x)=~s/\./[.]/g;s/^$y .+
//gm,delete$a{$x}if/$y/&&!/^(\S+) (?!\1$)$y$/m&&print$x}}print
for keys%a;$_&&die
162.48 Bruce Gray Mon Jul 1 19:20:47 2002
-ln /(\S+) +(.+)/;$n{$1}+=0;++$n{$2},push@{$s{$1}},$2if$1ne$2;END{@_=grep!$n{$_},keys%n;print&&push@_,grep!--$n{$_},@{$s{$_}}while$_=pop@_;$n{$_}&&die for keys%n}
163.50 FatPhil Mon Jul 1 17:31:29 2002
for(<>){/ (\S+)/;$p{$1}.=" $` "if($`ne$1);$p{$`}.=''}for(;;$f=''){map{$f||$p{$_}||print$f=$_,$/}keys%p;$f?delete$p{$f}:each%p?die:last;map$p{$_}=~s/ $f //g,keys%p}
First hack: 500 inc debug, 200 without Using everything I know aboutperl I've squeezed it to 163. YOU GUYS ARE NOT HUMAN! :-D
164.47 Sec Mon Jul 1 18:40:48 2002
-lan $t{$F[1]}{$F[0]}=1if($F[0]ne$F[1]);$t{$F[0]}{a}}for(keys%t){for(keys%t){if(!%{$t{$_}}){print;delete$t{$d=$_};last}}die if!$d;map{delete$t{$_}{$d}}keys%t;$d="";
A few more easy optimisations: for->map, omit 'scalar' or 'keys' here and there.
164.53 Martin Carlsen Mon Jul 1 12:32:05 2002
-pl sub i{my($b,$n)=@_;($n{$b}=++$n)>$.&&die;i($_,$n)for@{$g{$b}}}/ /;$n=$n{$`}=$n{$`};$`eq$'&&next;push@{$g{$`}},$';i($',$n)}{$_=join$\,sort{$n{$a}<=>$n{$b}}keys%n
165.45 Qingning Huo Mon Jul 1 09:53:25 2002
-ln0 $n=map$a{$_}++,split;s/(\S+) \1
//gm;while($n--){for$x(keys%a){($y=$x)=~s/\./[.]/g;s/^$y .+
//gm,delete$a{$x}if/$y/&&!/ $y$/m&&print$x}}print for keys%a;$_&&die
165.46 Dave Hoover Wed Jul 3 12:02:45 2002
-pal @g{@F}=($u,$v)=@F;$v eq$u||push@{$f{$v}},$u}sub Y{my($y,@c)=@_;"@c"=~/ \Q$y /&&exit 1;push@c,$y;push@c,map{Y($_,@c)}@{$f{$y}};@c}for(sort{Y($a)<=>Y($b)}keys%g){
Hack, Hack, Hack
165.51 Prakash Kailasa Mon Jul 8 01:29:41 2002
-lan $i{$_}++||push@{$h{$F[1]}},$F[0];$h{$F[0]}||=[]}{sub d{my($w,$d,$x)=@_;map{$d>$.&&die;$x+=1+d($_,++$d)if$_ ne$w}@{$h{$w}};$x}map{print}sort{d($a)<=>d($b)}keys%h
It passes the test program but takes more than 6 minutes my Duron 600MHz box. Will it get me out of the sandtrap (and barely onto the board)?
166.51 Terje K Mon Jul 1 18:44:46 2002
-lna $h{$F[0]}||=0;$h{$F[1]}||=$F[0]if$F[1]ne$F[0]}{@t=0;while(%h){@m=();$o=1;for(keys%h){for$t(@t){if($h{$_}eq$t){print;push@m,$_;delete$h{$_};$o=0}}}$o&&last;@t=@m}
first effort
168.49 Chris Dolan Mon Jul 1 16:20:07 2002
-pal push@{$a{$F[0]}},$F[1];exit 1if grep{/^$F[0]$/&&!/^$F[1]$/}@{$a{$F[1]}}}sub t{$_[0],map{t($_)}@{delete$a{$_[0]}}}unshift@t,grep!$c{$_}++,t(keys%a)while+%a;for(@t){
Oops, had a copy-n-paste error in the previous entry
169.48 Trevor Leffler Fri Jul 5 18:49:48 2002
-lan ($a,$b)=@F;push@{$h{$a}},$a ne$b?$s{$b}=$b:();END{@v=grep{!$s{$_}}keys%h or exit
 1;while(@v){for(@v){$p{$_}&&exit 1;print;@b{@{$h{$_}}}=$p{$_}++}@v=keys%b;%b=()
}}
Pretty much the "standard algorithm" that you find in the Net. At least it's sub-200...
170.50 Chris Dolan Mon Jul 1 16:19:21 2002
-pal push@{$a{$F[0]}},$F[1];exit 1if grep{/^$F[0]$/&&!/^$F[1]$/}@{$a{$F[1]}}}sub t{$_
[0],map{t($_)}@{delete$a{$_[0]}}}unshift@t,grep!$c{$_}++,t(keys%a)while+%a;for(@
t){
179.54 tinita Thu Jul 4 10:20:25 2002
-lan sub k{keys%{$_[0]}}m/ /;$`eq$'?$o{$`}||={}:$o{$`}{$'}++;END{sub _{$g{$_}--||die,$s{$_}++||print
for@_;_(k($o{$_}))for@_}@g{map
k($_),%o}=k\%o;(@_=grep!$g{$_}++,k\%o)||die;&_}
180.52 Dave Hoover Wed Jul 3 10:51:25 2002
-pal @g{@F}=($u,$v)=@F;$v eq$u||push@{$f{$v}},$u}sub Y{my($y,$i,$c)=@_;$c=~/ \Q$y /&&exit 1;$c.=" $y";$i++;(map{$i+=Y($_,$i,$c)}@{$f{$y}})[-1]||$i|0}for(sort{Y($a)<=>Y($b)}keys%g){
183.52 Martin Carlsen Mon Jul 1 12:10:24 2002
-nl sub i{my($b,$n)=@_;($n{$b}=++$n)>$.&&die;for(@{$g{$b}}){i($_,$n)}}/ /;if($`eq$'){$n{$`}=0;next}push@{$g{$`}},$';i($',$n{$`}=$n{$`});END{print join"\n",sort{$n{$a}<=>$n{$b}}keys%n}
Look, no -pn!
186.43 Matthias Schoder Wed Jul 3 14:31:29 2002
-lan057 @N=grep{!$N{$_}++}@F;%X=@F;END{while(@N){exit 1if%X&&$i++>@N;$n=shift@N;delete$X{$n}if$X{$n}eq$n;%Y=reverse%X;if(!$Y{$n}){print$n;delete$X{$n};$i=0;%Y=reverse%X}else{push@N,$n}}}
186.53 Dave Hoover Wed Jul 3 10:32:43 2002
-pal @g{@F}=($u,$v)=@F;$v eq$u||push@{$f{$v}},$u}sub Y{my($y,$i,$c)=@_;$c=~/ \Q$y /&&exit 1;$c.=" $y";$i++;$f{$y}?(map{$i+=Y($_,$i,$c)}@{$f{$y}})[-1]:$i|0}for(sort{Y($a)<=>Y($b)}keys%g){
Pass the trout, I need a breakthrough.
189.44 Sec Mon Jul 1 18:30:01 2002
-lan $t{$F[1]}{$F[0]}=1if($F[0]ne$F[1]);$t{$F[0]}{a}}for(1..scalar keys%t){for(keys%t){if(!scalar keys%{$t{$_}}){print;delete$t{$_};$d=$_;last}}die if!$d;for(keys%t){delete$t{$_}{$d}}$d="";
Try my file obfuscator for obvious gains in whitespace.
191.49 Dave Hoover Wed Jul 3 01:28:06 2002
-pal @g{@F}=($u,$v)=@F;$u eq$v||push@{$f{$v}},$u}sub Y{my($y,$i,@c)=@_;exit 1 if grep{$_ eq$y}@c;push@c,$y;$i++;$f{$y}?(map{$i+=Y($_,$i,@c)}@{$f{$y}})[-1]:$i|0}for(sort{Y($a)<=>Y($b)}keys%g){
Whew, that's one ugly mess! Let the golfing begin!
191.54 RRBuonanno Wed Jul 3 13:20:37 2002
-nal ($x,$y)=@F;($a,$b)=@o{$x,$y};$b&&$b<$a&&die;@o{$x,$y}=$x eq$y?(0,0):($a=$a||9*$.,$b||$a+1);$b&&map{$o{$_}+=$o{$x}if$x ne$_&&$o{$_}>=$b}keys%o;END{$,=$\;print sort{$o{$a}<=>$o{$b}}keys%o}
...at least it's an entry.
193.38 Keith Calvert Ivey Mon Jul 1 12:55:49 2002
-lna0 @s{@F}=();$s{$2}{$1}++while/(.+) (?!\1
)(.+)/g;for(keys%s){for$h(values%s){$h==$_ or@{$h}{keys%{$s{$_}}}=@F for keys%$h}$s{$_}{$_}&&die}print for sort{keys%{$s{$a}}<=>keys%{$s{$b}}}keys%s
First version that passed. I'm submitting it despite its messiness and despite being last on the board. Maybe the score will encourage other high submissions.
200.43 Matthias Schoder Wed Jul 3 15:38:59 2002
-lan057 @N=grep{!$N{$_}++}@F;%X=@F;%Y=reverse@F;END{while(%X){exit 1if%X&&$i++>@N;$n=shift@N;delete$X{$n}if$X{$n}eq$n;if(!$Y{$n}){print$n;delete$X{$n};$i=0;%Y=reverse%X}else{push@N,$n}}map{print$_}@N}
205.50 Philippe 'BooK' Bruhat Tue Jul 2 13:08:35 2002
-lna $a{$F[0]}{$F[1]}++;$F[0]ne$F[1]?$r{$F[1]}++:next;exit 1if$a{$F[1]}{$F[0]};sub a{my%b;do{$d{$_}++||print;@b{keys%{$a{$_}}}=();delete$b{$_}}for@_;$i++>99&&exit 1;a(keys%b)if%b}END{a grep{!$r{$_}}keys%a}
This one is my first working attempt. Quite lame, particularly the $i++>99&&exit 1 part, that is used to detect cycles....
207.49 Chris Dolan Mon Jul 1 15:57:39 2002
-nal $n{$F[1]}++;push@{$a{$F[0]}},$F[1];exit 1 if grep{/^$F[0]$/&&$F[0] ne$F[1]}@{$a{$F[1]}}}sub t{$_[0],map{t($_)}@{delete$a{$_[0]}}}{unshift@t,grep!$c{$_}++,t(sort{$n{$a}-$n{$b}}keys%a)while+%a;print for@t
HARD problem!!!
214.49 Peter Haworth Wed Jul 3 12:46:51 2002
-nla ++$s{$_}for@F;$F[0]eq$F[1]||push@r,[@F]}&p(keys%s);sub p{$,=$/,print(@o),exit 0if!@_;for(@_){my$x=shift;$c{$o[$o++]=$x}=1,&p,$c{$x}=0,$o--if!grep{($,,$;)=@$_;$,eq$x&&$c{$;}||$;eq$x&&!$c{$,}}@r;push@_,$x}}die;{
This will probably land in the sand trap, too. This takes forever on the last test, but at least it uses constant memory this time
214.52 Matthias Schoder Fri Jul 5 12:44:19 2002
-lan012 ($.,$?)=@F;$X{$.}{$?}=$Y{$?}{$.}=1if$.ne$?;map{$N{$_}++}@F;END{for(0..%N){for(keys%N){if(!$Y{$_}){print;for$?(keys%Y){delete$Y{$?}{$_};delete$Y{$?}if!%{$Y{$?}}}delete$X{$_};delete$N{$_};exit if!%N}}}exit 1}
216.49 Brad Jones Tue Jul 2 00:07:05 2002
-nl ($a,$b)=split;($a ne$b)&&push@{$l{$b}},$a;$l{$a}||=[];END{while(%l){@j=sort{@{$\
l{$a}}<=>@{$l{$b}}}keys%l;$c=shift @j;(@{$l{$c}})&&exit(1);print$c;delete$l{$c}\
;foreach$d(@j){$l{$d}=[grep{$_ ne$c}@{$l{$d}}];}}}
227.44 Philippe 'BooK' Bruhat Wed Jul 3 14:09:34 2002
-lna @n{map{"\Q$_"}@F}=push@r,$_;END{$"=",";@t=glob
"{@{[keys%n]}}$;"x keys%n;T:for(@t){$_=$;.$_;/
$;([!-~]+$;).*\1/x&&next;@s{@s}=0..(@s=split$;
);for(@r){($a,$b)=split;next T if$s{$a}>$s{$b}
}print join$/,@s[1..$#s];exit}die}
This one is very greedy on memory... It asks glob to precompute all the possibilities (and even more!), and then uses the same algorithm as tpr04b.pl to print the first correct one. Since there are $n**$n possibilities ($n being the number of nodes in the graph), it eats up memory very fast!
243.50 Sec Mon Jul 1 18:25:49 2002
-lan 
^I$t{$F[1]}{$F[0]}=1 if($F[0] ne$F[1]);
^I$t{$F[0]}{a};
}

for(1..scalar keys%t){
^Ifor(keys %t){
^I^Iif(!scalar keys%{$t{$_}}){
^I^I^Iprint;
^I^I^Idelete $t{$_};
^I^I^I$d=$_;
^I^I^Ilast;
^I^I};
^I};
^Idie if!$d;
^Ifor(keys %t){
^I^Idelete $t{$_}{$d};
^I};
^I$d="";
Try the file upload box so formatting is kept sane.
243.56 Philippe 'BooK' Bruhat Tue Jul 2 17:10:09 2002
-lna $_="\Q$_"for@F;$b=0;for$a(@a){$b||$a=~s/ +($F[1]|$F[0]) +/ $_ /&&++$b;@c=$a=~/ (\S+) $/g;$_ eq$a&&next,s/^ @c /$a/&&($a='')for@a}push@a," $_ " if!$b;s/( [!-~]+)\1 /$1 /,/( [!-~]+ ).*\1/&&exit 1for@a;END{$_="@a";s/^ +| +$//g;y/ /
/s;print}
I guess I can shave some more, but to butcher this one, I'll have to change my algorithm. (Changed $c to @c)
247.56 Philippe 'BooK' Bruhat Tue Jul 2 17:03:48 2002
-lna $_="\Q$_"for@F;$b=0;for$a(@a){$b||$a=~s/ +($F[1]|$F[0]) +/ $_ /&&++$b;($c)=($a=~/ (\S+) $/g);$_ eq$a&&next,s/^ $c /$a/&&($a='')for@a}push@a," $_ " if!$b;s/( [!-~]+)\1 /$1 /,/( [!-~]+ ).*\1/&&exit 1for@a;END{$_="@a";s/^ +| +$//g;y/ /
/s;print}
Shortening quotemeta, and using the aliasing capabilities of for.
252.55 Philippe 'BooK' Bruhat Tue Jul 2 16:59:25 2002
-lna @F=map{quotemeta}@F;$b=0;for$a(@a){$b||$a=~s/ +($F[1]|$F[0]) +/ $_ /&&++$b;($c)=($a=~/ (\S+) $/g);$_ eq$a&&next,s/^ $c /$a/&&($a='')for@a}push@a," $_ " if!$b;s/( [!-~]+)\1 /$1 /,/( [!-~]+ ).*\1/&&exit 1for@a;END{$_="@a";s/^ +| +$//g;y/ /
/s;print}
I thought I found a better approach than the previous one... I hope at least that this one won't be rejected. :-)
278.46 Peter Haworth Wed Jul 3 10:31:40 2002
-an 
  $set{$_}++||push@set,$_ for@F;
  $F[0]eq$F[1]or$rerules.=qr/(?>(?=(?>.*?^\Q$F[0]\E$).*^\Q$F[1]\E$))/ms;
}
sub perm{
  my@a;
  for(@_){
    my$x=shift;
      push@a,"$x\n$_"for&perm;
    push@_,$x;
  }
  @a?@a:'';
}

for(&perm(@set)){
  /$rerules/and print(),exit 0
}
die;

{
This seems to work, but is probably the least efficient program I have ever written, so I expect the sand trap for my efforts
316.48 Ryan Zachry Wed Jul 3 04:03:25 2002
-l while(<>){($l,$r)=split;exit(2)if$x{$r}{$l};if($l ne$r){$x{$l}{$r}=1;$s{$r}++}push@{$p{$l}},$r}@n=@o=grep{!$s{$_}}@q=keys%p;map{print if!$o[0]}@q;while(@o){$z=pop@o;print$z;map{exit(3)if$t{$_}>10;push@o,$_ if!--$s{$_}}@{$p{$z}}}while($_=pop@n){$t{$_}++;exit(4)if$t{$_}>300;push@n,@{$p{$_}};exit(0)if$x eq$_;$x=$_}
322.47 Ryan Zachry Wed Jul 3 11:44:21 2002
-l while(<>){($l,$r)=split;exit(2)if$x{$r}{$l};if($l ne$r){$x{$l}{$r}=1;$s{$r}++}push@{$p{$l}},$r}@n=@o=grep{!$s{$_}}@q=keys%p;map{print if!exists$o[0]}@q;while(@o){$z=pop@o;print$z;map{exit(3)if$t{$_}>10;push@o,$_ if!--$s{$_}}@{$p{$z}}}while($_=pop@n){$t{$_}++;exit(4)if$t{$_}>300;push@n,@{$p{$_}};exit(0)if$x eq$_;$x=$_}
410.54 Sec Mon Jul 1 18:11:14 2002
-lan 
$t{$F[1]}{$F[0]}=1 if($F[0] ne$F[1]);;
$t{$F[0]}{""};
}

{

        for(1..scalar keys%t){
for$a(keys %t){
#       print "Looking at $a: ",scalar keys(%{$t{$a}});
        if(!scalar keys%{$t{$a}}){
                print $a;
                delete $t{$a};
                $d=$a;
                last;
        };
};
die if!$d;
for$a(keys %t){
#       print "Del $a,$d";
        delete $t{$a}{$d};
};
$d="";
};
My first working solution *uff*
517.48 Kristen Thelen Thu Jul 4 05:02:22 2002
my @l, @o;sub visit{if (@{$l{$_[0]}}[0] != 0){return;}@{$l{$_[0]}}[0]=1;$count=0;foreach $v (@{$l{$_[0]}}){if ($count ne 0){if ($v eq $_[1]){exit 1;}visit($v, $_[1]);}$count++;}@{$l{$_[0]}}[0]=2;unshift(@o, $_[0]);return;}while (<>) {($f, $s) = split;if (!@{$l{$f}}){push @{$l{$f}}, 0;   }if (!@{$l{$s}}){push @{$l{$s}}, 0;   }if ($f ne $s){$found = 0;foreach $item (@{$l{$f}}){if ($item eq $s){$found = 1;}}if (!$found){push @{$l{$f}}, $s;   }}}foreach $key (keys %l){visit($key, $key);}foreach $i (@o){print "$i
";}
I'm a beginner in both perl and perl golf, but enjoyed this exercise anyway. Thanks!
555.49 Kristen Thelen Thu Jul 4 05:30:52 2002
my @l, @o;sub visit{if (@{$l{$_[0]}}[0] != 0){return;}@{$l{$_[0]}}[0]=1;$count=0;foreach $v (@{$l{$_[0]}}){if ($count ne 0){if ($v eq $_[1]){exit 1;}visit($v, $_[1]);}$count++;}@{$l{$_[0]}}[0]=2;unshift(@o, $_[0]);return;}while (<>) {($f, $s) = split;if (!@{$l{$f}}){push @{$l{$f}}, 0;   }if (!@{$l{$s}}){push @{$l{$s}}, 0;   }if ($f ne $s){$found = 0;$count =0;foreach $item (@{$l{$f}}){if (($count ne 0) && ($item eq $s)){$found = 1;}$count++;}if (!$found){push @{$l{$f}}, $s;   }}}foreach $key (keys %l){visit($key, $key);}foreach $i (@o){print "$i
";}
Here we go again
588.59 Dave Hoover Mon Jul 8 04:57:18 2002
-pal @g{@F}=/^\Q$F[1] /||($f{$F[0]}{$F[1]}='')}

$_ = " $F[0] ";
while (%g) {
    $i =0;
    for $k(keys %g) {
        if (s/ \Q$k\E /join'',map {delete $g{$_};" $_ "}( $k, keys %{$f{$k}})/e) {
            $i++;last;
        }
    }
    if(!$i) {
    for $k(keys %g) {
       $l = $k;
       for $j(keys %{$f{$k}}) {
        if (s/ \Q$j\E / $k $j /) {
            delete $g{$k};
            $i++;last;
        }
       }
    }

    }

    if(!$i) {
     $_.=" $l ";
     delete $g{$l}
    }
}


for $x(split){
   for $k(keys %{$f{$x}}) {
       / \Q$x\E .*\Q$k\E .*/ or die;
   }
}

for(split){
So sad. Once again, foiled by the 200 line test. Ran out of time...