Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re: Algorythm for searching closest neighborby gryng (Hermit) |
on Apr 04, 2001 at 02:31 UTC ( [id://69500]=note: print w/replies, xml ) | Need Help?? |
I'm not sure what you want -- closest digits, or closest location? But for closest digits, in a left right precedence, all you need is a sorted list of zip codes. Then you do a binary search for the number. If it succeeds, good. If not, then where it ends will either be the closest number or else the one above or below it will be.
If you need closest location then that can be done quickly too, but you need the locations first. Ciao,
In Section
Seekers of Perl Wisdom
|
|