Topological Sort

Score: 118.55 (pass)

Would that dirty trick be my final swing at this hole?

#!perl -lpa
push@;,[@F[$F[0]eq$_..1]]for@F}while(/.+/,map{@$_=grep$&ne$_,@$_}@;){($_)=map{(($x)=@$_)x!grep$$_[1]eq$x,@;}@;or&

Score: 119.54 (pass)

Woohoo! Sub-120!

#!perl -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&

Score: 125.54 (fail)

A Perl golf solution without a regex is not a true Perl golf solution.

#!perl -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&

Score: 127.54 (fail)

I think it's about time I have a satori. Or an epiphany. Or just a good idea (I'm not picky).

#!perl -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:&

Score: 128.54 (fail)

Argh. That's all I have to say: argh.

#!perl -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:&

Score: 129.54 (fail)

Why be dirty when we can be dirtier?

#!perl -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:&

Score: 130.54 (pass)

BWAH! I had forgotten about this über-dirty trick!

#!perl -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:&:

Score: 131.53 (pass)

Did I mentioned already how hilarious I find that grep!grep construct?

#!perl -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

Score: 133.52 (pass)

gooble gooble gooble

#!perl -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

Score: 136.51 (pass)

What I wouldn't give to borrow Ton's brain for a few hours...

#!perl -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

Score: 137.50 (pass)

Sec, okay. |3en, it's hard. But. /-\. will. *not* beat. me.

#!perl -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

Score: 139.51 (fail)

Okay, enough for tonight...

#!perl -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

Score: 142.51 (pass)

So much for so little.

#!perl -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

Score: 143.53 (pass)

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).

#!perl -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

Score: 152.53 (fail)

Totally different approach, same crummy score...

#!perl -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

Score: 156.42 (pass)

*whistling that 'Barber of Seville' tune*

#!perl -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

Score: 164.41 (pass)

Okay, enough for tonight.

#!perl -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]}||=[]

Score: 168.41 (pass)

Not very efficient, but I find it cute, in an unwholesome manner.

#!perl -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]}||=[]

Score: 176.43 (pass)

Of course, using a string and regexes is probably the way to go. But arrays want love, too!

#!perl -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]}||=[]

Score: 191.43 (pass)

Just testing the ground...

#!perl -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]}||=[]

Score: 203.39 (pass)

It's a start...

#!perl -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}