Planning the ultimate U.S. road trip requires more than an atlas — it takes an algorithm.

When a producer at Discovery News challenged Michigan State University doctoral student Randy Olson to plot the optimum route across the continental U.S., Olson got to work charting a course within these parameters:

• There would be one stop in all 48 contiguous U.S. states, as well as Washington D.C. and two stops in California for an even 50 stops.
• Each stop would be at a national natural landmark, national historic site, national park or national monument.
• The vehicle would never leave U.S. soil.

Olson's first step was to take the list of 50 landmarks he was provided and find the shortest distance by road between each one.

Once he had this information, he approached the task as a traveling salesman would. In other words, he had to put the landmarks in such an order that the driver would backtrack as little as possible, which is especially difficult when making stops in Florida and the Northeast.

To do this, Olson used information from Google Maps API and wrote a bit of code to determine the distance and time it would take to drive to all 50 landmarks.

It would take millions of years for a computer to look at every possible solution, so he employed a genetic algorithm — the same one he used to devise the best way to find Waldo — to find a "near-perfect solution."

If you were to follow this 13,699-mile route and had the road entirely to yourself, it would take 9.33 days of nonstop driving, according to Olson's calculations.

However, in reality you'd have to commit two to three months to complete the ultimate road trip.

Considering embarking on such an epic trip? Olson's course is designed so you can start anywhere on the route, and many of the destinations are also near other tourist sites.

"You'll hit every major area in the U.S. on this trip, and as an added bonus, you won't spend too long driving through the endless cornfields of Nebraska," he wrote on his blog.

If you're looking to optimize your time in urban settings, Olson also created a second U.S. road trip map that makes stops at the top-ranked TripAdvisor cities.

The second trip is 12,290 miles long and follows a similar path; however, it bypasses North Dakota, Vermont and West Virginia because none of these states are represented in TripAdvisor's top 400 cities.

"This is especially interesting because TripAdvisor reviewers recommend cities like Flint, Michigan — the seventh most crime-ridden city in the U.S. — over any city in North Dakota, Vermont and West Virginia. I'll leave the interpretation of that fact to the reader," Olson wrote.

Olson also created an ideal European road trip, and he's released the code he used to create it, meaning you can optimize your own custom route.

Below is a list of the destinations you'll see if you follow his ultimate road trip route:

1. Grand Canyon, Arizona
2. Bryce Canyon National Park, Utah
3. Craters of the Moon, Idaho
4. Yellowstone National Park, Wyoming
6. Carlsbad Caverns National Park, New Mexico
7. The Alamo, Texas
8. The Platt Historic District, Oklahoma
9. Toltec Mounds, Arkansas
10. Elvis Presley’s Graceland, Tennessee
11. Vicksburg National Military Park, Mississippi
12. French Quarter, New Orleans, Louisiana
13. USS Alabama, Alabama
14. Cape Canaveral Air Force Station, Florida
15. Okefenokee Swamp Park, Georgia
16. Fort Sumter National Monument, South Carolina
17. Lost World Caverns, West Virginia
18. Wright Brothers National Memorial Visitor Center, North Carolina
19. Mount Vernon, Virginia
20. White House, Washington, D.C.
21. Colonial Annapolis Historic District, Maryland
22. New Castle Historic District, Delaware
23. Cape May Historic District, New Jersey
24. Liberty Bell, Pennsylvania
25. Statue of Liberty, New York
26. The Mark Twain House & Museum, Connecticut
27. The Breakers, Rhode Island
28. USS Constitution, Massachusetts
30. Mount Washington Hotel, New Hampshire
31. Shelburne Farms, Vermont
32. Fox Theater, Detroit, Michigan
33. Spring Grove Cemetery, Ohio
34. Mammoth Cave National Park, Kentucky
35. West Baden Springs Hotel, Indiana
36. Abraham Lincoln’s Home, Illinois
37. Gateway Arch, Missouri
38. C. W. Parker Carousel Museum, Kansas
39. Terrace Hill Governor’s Mansion, Iowa
40. Taliesin, Wisconsin
41. Fort Snelling, Minnesota