
PUZZLE 75 FINDING A PUB 309
PUZZLE
75 FINDING A PUB
This is a common problem for simple maps. The original version of this
problem was based on the location of pubs in a city, so that when we got
kicked out of one pub, we could locate nearby ones to which to crawl.
The map we use is an (x, y) Cartesian system, which looks like this:
CREATE TABLE PubMap
(pub_id CHAR(5) NOT NULL PRIMARY KEY,
x INTEGER NOT NULL,
y INTEGER NOT NULL);
What I would like is an efficient method for finding the group of
points within a neighborhood.
Answer #1
The immediate solution is to use the Cartesian distance formula,
d = √((x1-x2)
2
+ (y1- y2)
2
), and to define a neighborhood ...