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 Revisited

Sunday November 8, 2009

Thanks to John Downey, Pedro Graca, Stuart Highman and Kenneth D Weinert for early entries (I've marked the first two and will carry on marking as entries are received). Also, thanks to the commenters regarding the asymmetric distance calculation (not the same distance in each direction!). I found this page on distance calculations

a = pi/2 - lat1
b = pi/2 - lat2
c = sqrt(a^2 + b^2 - 2 * a * b * cos(lon2 - lon1)
d = R * c

Use R= 3956(miles). I know the Earth isn't a sphere- it's an oblate spheroid because the rotation of the Earth makes it bulge slightly at the equator but it's ok for this challenge.

The first times are

  1. Pedro Graca 1.567 seconds
  2. John Downey 1.658 seconds
Both entries are written in C#.

Comments
November 9, 2009 at 3:04 am
(1) Lennie De Villiers says:

Hi David: Since you provided the times, can they re-submit there entries to try to make it run faster? Lennie

November 11, 2009 at 5:50 pm
(2) cplus says:

Yes, as often as desired until the challenge finishes.

David
About C,C++ and C#

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

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

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

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

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

All rights reserved.