
PUZZLE 64 BOXES 257
PUZZLE
64 BOXES
This is an interesting puzzle from Mikito Harakiri. Imagine that you have
a Cartesian space, and you are filling it with n-dimensional boxes. The
boxes are modeled as shown below:
CREATE TABLE Boxes
(box_id INTEGER NOT NULL PRIMARY KEY,
dimension_nbr INTEGER NOT NULL,
low INTEGER NOT NULL,
high INTEGER NOT NULL);
The problem is to find all the pairs of boxes that intersect (e.g., the
3D cubes):
A = {(x,0,2),(y,0,2),(z,0,2)}
B = {(x,1,3),(y,1,3),(z,1,3)}
C = {(x,10,12),(y,0,4),(z,0,100)}
Boxes A and B intersect, but box C intersects neither A nor B. Bonus
point: is there anything special about this kind of query? ...