It's nigh-inevitable that every baseball season, there will be some fan or other who makes an attempt to visit all 30 major league ballparks. Last season was no exception, with Ben Blatt and Eric Brewster endeavoring to visit them all within a scant 30 days. This didn't merely require a Herculean driving effort, lots of lost sleep, luck with extra innings and no rainouts. It required an algorithm- which they could do, being from Harvard and all. It required a set of dates that permitted all 30 stadiums to be visited one by one by car within that time, and it also required those car trips to be halfway drivable. Blatt and Brewster based the trip they took on the optimal route their algorithm spit out, which for them ran about 18,000 miles.
The rules they laid down were to allow four hours for each game, though you had to be there for every single pitch of the ballgame. The object is to complete the trip in under 30 days while maximizing the time spent between cities, so as to permit easier drives. The algorithm also makes efforts to reduce breakneck driving as much as possible, so that you're not trying to make a long-haul drive with only a one hour grace period. An additional rule is that you also have to drive back to your starting point before the 30 days are up. If you begin at Miller Park with a Brewers game, you have to get yourself back to Milwaukee after your 30th game, so the algorithm will generally be nice enough to place your 30th game at a nearby stadium, say, Wrigley Field or Comerica Park.
Human fatigue is accounted for only in the sense that the longest leg of the journey is given as much time as possible.
Usually these trips allow for the traveler to use the entire season to get the job done, so they can take a day off here and there and actually enjoy the scenery. But if you're not one of these people and enjoy pain pain pain, Slate has a copy of the algorithm here to use to your leisure. You pick the starting stadium, then pick a starting date, and it'll do the rest of the work for you... unless there isn't a way to make it work without the aid of a TARDIS, in which case the date simply isn't selectable for that stadium.
The trip suggested by Blatt and Brewster, the optimal route from the remaining portion of the season, dumps you in Oakland to start on May 30, mandates you to drive to Seattle first, and then gives you two days to get from Seattle to Milwaukee. You're supposed to get from a Washington night game to a Cincinnati day game to a Colorado night game the next day, as well as a similar day-to-next-night drive from Baltimore to Miami. You're given one doubleheader towards the end, when you have to get from a Dodgers day game to an Angels night game. This will run you 16,927 miles overall.
But what if you're crazy? What if you looked for the most obnoxious route possible, like I did? While it may or may not be the longest route provided- probably not- it is plenty long enough. The route I found begins at Coors Field in Denver on July 23, and has four doubleheaders on it: Padres day game to Dodgers night game, Mets day game to Yankees night game, White Sox day game to Brewers night game, and Phillies day game to Orioles night game. Your route starts out as Colorado, Seattle, LA Angels, San Francisco, two days to Houston, one day to Chicago Cubs, one and a half days to San Diego. You're expected to cannonball run from Phoenix to the Mets/Yankees doubleheader in a day and a half. There's a drive from Miami to Cleveland to Arlington. You'll be transitioning from night games to early games the next day on your way from Pittsburgh to the White Sox, Atlanta to Detroit, and from St. Louis to your final game in Minnesota. And then, from Minnesota, you will be spending your final day driving from Minneapolis to Denver without even a baseball game to entice you to keep going. All you're trying to do is beat the clock.
That's 25,333 miles in 23 days, 19 hours.