Company
Date Published
Author
Bryan Reinero
Word count
1388
Language
English
Hacker News points
None

Summary

The Traveling Santa problem is a classic challenge in computer science where one must find the shortest path to visit all cities on Earth, given their geo-coordinates. MongoDB provided a dataset containing 10 of the most populous urban areas, including the North Pole, and challenged developers to solve the problem. Dror Asaf's solution, which used geospatial indexing and queries in MongoDB, found the correct path for Santa to reach each city in the least distance required. However, this solution was not a general one, and the author admitted to making an error in the original dataset. The author then provided a corrected solution that used a recursive function to traverse paths and find the shortest among them. This solution involved calculating distances between cities using the Haversine formula and representing these distances as edge documents in MongoDB. The solution was exhaustive and brute force, but the author encouraged readers to optimize it further.