Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: (Golf) Nearest Neighbors

by satchboost (Scribe)
on Apr 04, 2001 at 19:14 UTC ( #69694=note: print w/ replies, xml ) Need Help??


in reply to (Golf) Nearest Neighbors

While this may not have many new ideas, it does weigh in at 117 characters and deal with dups:

sub nn2 { my$s=sub{sort{$a<=>$b}keys%_}; @_{@_}=0;@_=&$s;%_=(); $_{abs($_[$_]-$_[$_+1])}=[@_[$_,$_+1]]for 0..$#_; @{$_{(&$s)[0]}} }

Neat problem!


Comment on Re: (Golf) Nearest Neighbors
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://69694]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (13)
As of 2015-07-31 16:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (279 votes), past polls