in reply to (Golf) Nearest Neighbors
As Tortue points out, all the ones using lexigraphic sorting fail on some sets of numbers. Stripping leading spaces and newlines, my stab weighs in at 87 characters:
sub nn { @_=sort{$a<=>$b}@_; $_[1]-$_[0]>$_[$_+1]-$_[$_]and@_[0,1]=@_[$_,$_+1]for 1..@_-2; @_[0,1] }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: (Golf) Nearest Neighbors
by MeowChow (Vicar) on Apr 04, 2001 at 23:45 UTC | |
by satchboost (Scribe) on Apr 05, 2001 at 00:23 UTC |
In Section
Obfuscated Code