This piece originally appeared on Travel + Leisure.
Hitting the open road and driving into the sunset is a romantic notion, but most of us need a little planning before road trip.
Do you go north? Do you go south? Do you take a week? Do you take a month? What are the best stops to make? And there are a million more questions to be asked.
Related: The World's Most Dangerous Roads
Randy Olson, a postdoctoral researcher at the University of Pennsylvania, mapped out a super-efficient — and super-ambitious — way to see the contiguous United States. He devised his cross-country road trip, combining algorithms and Google Maps, so he could visit 48 capitol buildings.
“For this road trip, there is one goal: to take a picture at as many U.S. state capitols as possible,” Olson wrote on his blog. “We will travel only by car, so that rules out Alaska (too far away) and Hawaii (requires a plane flight) and leaves us with the 48 contiguous states (excluding D.C.).”
Related: The Ultimate Florida Beach Road Trip
“Whenever possible, we will avoid routes that require us to travel through foreign countries, as entering/leaving the country requires a passport and border control tends to slow things down.”
To start, he found the “true” distance between all of the capitols by car, and then the shortest route by road between every capitol, amounting to 2,256 directions. He did a lot more math — you can read that here — before determining his final itinerary.
The algorithm “reached an optimized solution that makes a complete trip to all of the U.S. state capitols in only 13,310 miles (21,420 km) of driving,” he wrote. That came out to visiting those 48 U.S. state capitols in 8.5 days.
“The best part is that this road trip is designed so that you can start anywhere on the route,” he noted. “As long as you follow the route from wherever you start, you’ll hit every state capitol in the 48 contiguous U.S. states.”
The full map: