note
tilly
Why have a loop?
<code>
sub nn {
my@x=@_[0,1];@_=sort{abs$x[0]-$x[1]<abs$a-$b or@x=($a,$b);$a<=>$b}@_;@x
}
</code>
(75...)<P>
<B>UPDATE</B><BR>
[MeowChow] pointed out that the parens for the arguments
of [abs] were not needed. That cut out 3 characters.
Plus by reversing the order of the comparison I managed
to substitute or for and, saving another. That makes it
71...<P>
<B>UPDATE 2</B><BR>
This is sick and slick.
<code>
sub nn {
()=sort{abs$_[0]-$_[1]<abs$a-$b or@_=($a,$b);$a<=>$b}@_;@_
}
</code>
Enjoy verifying that I am perfectly safe in using @_ as my
temporary array. I think that 58 is the best I can do...
<P>
<B>UPDATE 3</B<BR>
[petral] sent me a /msg explaining how to remove 3 chars
from that solution. I would like to see him post that
since it was his idea, but until he does I want to note
that that solution can be beaten.
69570
69570