title: Finding the farthest point in one set from another set
body: <p>My goal is a more efficient implementation of the algorithm posed <a href="https://stackoverflow.com/questions/589145/what-does-this-mysterious-color-method-do-what-does-it-return">in this question</a>.</p>
  
  <p>Consider two sets of points (in N-space.  3-space for the example case of RGB colorspace, while a solution for <strike>1-space</strike> 2-space differs only in the distance calculation).  How do you find the point in the first set that is the farthest from its nearest neighbor in the second set?</p>
  
  <p>In a 1-space example, given the sets A:{2,4,6,8} and B:{1,3,5}, the answer would be
  8, as 8 is 3 units away from 5 (its nearest neighbor in B) while all other members of A are just 1 unit away from their nearest neighbor in B.  edit: 1-space is overly simplified, as sorting is related to distance in a way that it is not in higher dimensions.</p>
  
  <p>The solution in the source question involves a brute force comparison of every point in one set (all R,G,B where 512>=R+G+B>=256 and R%4=0 and G%4=0 and B%4=0) to every point in the other set (colorTable).  Ignore, for the sake of this question, that the first set is elaborated programmatically instead of iterated over as a stored list like the second set.</p>