Traveling SalesPerson

Readme Homework


Episode 7 - Salesman Traveler

An o(n!) algorithm to travel the globe as fast as possible

Panda Level

  1. Implement your own route for errands around town. Is the algorithm making the same choices you would?
  2. Instead of assuming the first point is your starting point, tell the SalesPerson what their starting point is

Tiger Level

  1. Implement benchmarking code to see how long it will take to calculate for 2, 10, 50, and 200
  2. Sample benchmarking code: http://rubyfiddle.com/riddles/68404

Eagle Level

  1. Implement the "salesperson should log the total miles"
  2. Output the total traveling time (assume 55 mph)

Show Links

Sample Nokogiri Code

require 'nokogiri'
require 'open-uri'
doc = Nokogiri::HTML(open('http://www.texas.gov/en/discover/Pages/topic.aspx?topicid=/government/localgov'))
doc.css(".topic-subcategory-link a").map do |node|
  puts node.content
end

Copyright: Jesse Wolgamott, MIT License (See LICENSE)

Traveling SalesPerson

  • Area:

    Databases  
  • Runtime:

    1:25  
  • Tech:

    Mapping  
  • Tags:

    nokogiri geocoding  

The Traveling Salesperson.

We tackle a couple of cool stuff this week:
* Describing "algorithms" and what that means
* Benchmarking code (in the Tiger level)
* How to geocode an address into lat-lng and calculating distances
* Download a webpage, parse content out of it using Nokogiri

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

ABOUT RUBY OFF RAILS

Ruby Off Rails is dedicated to accelerating the mastering of Ruby and increasing developer happiness everywhere.

In my software training, I see two distinct sets of programmers: those who know Ruby, and those who haven’t learned it yet. People who learn Ruby have an easier time understanding Rails, gems, and what magic voodoo is going on. And most importantly, they can cast wicked voodoo themselves.