busbud/coding-challenge-backend-b — pull request #3 by sfllaw (2013-11-27 22:13:50+00:00)
Title: Coding challenge B

Here is a suggestions system that follows the specified API.

Performance is decent, but dominated by latency. The system caches all its information in memory, because auto-suggestions are typically done in real-time. Right now, the system stores things in a hash table, but that should really be a prefix-trie if we want to import all cities in the world.

The scoring engine is quite primitive. First, we only do exact prefix matching, which could be improved upon. Metaphone would be appropriate to match misspellings, like "Seatle" or "Brooklin". As well, distances are computed using a naive method, when really they should be done in great-circle distances, to prevent silliness near the poles and the date line.

I couldn't get rbenv to work reasonably on my machine, so this was developed on Ruby 1.9.3. It deployed properly to Heroku, so it looks like it works in Ruby 2.

Go to http://glacial-escarpment-8710.herokuapp.com/suggestions?q=Londo&latitude=43.70011&longitude=-79.4163 to test it out.