RGB value base color name

So if you want distance between 2 colors (r0,g0,b0) and (r1,g1,b1) to detect closest color regardless of its intensity (that is what base color means in this case) you should Normalize color vectors to common size Compute distance Scale the result back // variables int r0,g0,b0,c0; int r1,g1,b1,c1,d; // color sizes c0=sqrt(r0*r0+g0*g0+b0*b0); c1=sqrt(r1*r1+g1*g1+b1*b1); // distance … Read more

Fast solution to Subset sum

I respect the alacrity with which you’re trying to solve this problem! Unfortunately, you’re trying to solve a problem that’s NP-complete, meaning that any further improvement that breaks the polynomial time barrier will prove that P = NP. The implementation you pulled from Hacker News appears to be consistent with the pseudo-polytime dynamic programming solution, … Read more

How to find distance from the latitude and longitude of two locations?

The Haversine formula assumes a spherical earth. However, the shape of the earh is more complex. An oblate spheroid model will give better results. If such accuracy is needed, you should better use Vincenty inverse formula. See http://en.wikipedia.org/wiki/Vincenty’s_formulae for details. Using it, you can get a 0.5mm accuracy for the spheroid model. There is no … Read more