Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: (tye)Re2: (Golf) Nearest Neighbors

by MeowChow (Vicar)
on Apr 04, 2001 at 23:26 UTC ( [id://69825]=note: print w/replies, xml ) Need Help??


in reply to (tye)Re2: (Golf) Nearest Neighbors
in thread (Golf) Nearest Neighbors

Any solution which returns a pair of numbers that are in the list and represent a minimal distance from each other with respect to all other possible pairings is correct. We are comparing the distance between all possible number pairings, and returning a minimal one. So the following are all correct:
nn(1,5,9,15) returns (1,5) # or nn(1,5,9,15) returns (5,9) # or nn(1,5,9,15) returns (9,5)
I don't really understand the beginning of your question though.
   MeowChow                                   
               s aamecha.s a..a\u$&owag.print

Replies are listed 'Best First'.
(tye)Re4: (Golf) Nearest Neighbors
by tye (Sage) on Apr 04, 2001 at 23:39 UTC

    Ah! That's different!

    The specification is simple: given a list of numbers, return the two which are nearest to one-another

    I didn't parse the "one-" part (in my lame defense, my current window width wrapped the line right after the "-") so I was thinking you wanted the two numbers from a list closest to some other number not on the list.

    So just ignore me. (:

            - tye (but my friends call me "Tye")

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-20 06:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found