Challenge 29 Published
Friday October 30, 2009
This is a nice easy speed challenge. There are 10,000 treasure hunters located across the continental USA and likewise there are 250 treasures. You are given the latitude and longitude of both treasures and hunters and have to figure out which 10 treasures have the lowest average distance of hunters within 100 miles so you can assign them to search for the treasure. The challenge is only concerned with managing the hunters not the actual search.
If a hunter is more than 100 miles from a treasure don't count that hunter. So if the total distance of all 10 hunters from one treasure is 265 miles then the average distance of hunters from that treasure is 26.5 miles.
- Link to Programming Challenge Twenty Eight Optimize Fuel Transport
- Link to Programming Challenge Twenty Nine Manage the Hunters


The provided distance formula isn’t reflexive. That is, dist(p1,p2) != dist(p2,p1). Maybe use the (lat1 + lat2)/2 for the cosine factor?
Er, symmetric, not reflexive.
Hmmm … the wrong formula is about 4 times as fast