1. Home
  2. Computing & Technology
  3. C / C++ / C#
David Bolton
David's C / C++ / C# Blog

By David Bolton, About.com Guide to C / C++ / C#

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.

Comments
October 31, 2009 at 1:18 pm
(1) Mike says:

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?

October 31, 2009 at 3:37 pm
(2) Mike says:

Er, symmetric, not reflexive.

November 5, 2009 at 12:30 pm
(3) Pedro says:

Hmmm … the wrong formula is about 4 times as fast ;)

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Explore C / C++ / C#
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. C / C++ / C#

©2009 About.com, a part of The New York Times Company.

All rights reserved.