Xu ticks off all the vexing problems in rapid-fire: “How do you determine which driver should get which order? How do you time it so there’s no wasted time at the restaurant? If you get there too late, the food is already cold. How do you determine whether or not more than one order should go to a driver? What happens when you don’t have enough drivers out on the road? How do you estimate how long it takes to make something?”

The solution involves variations of the Traveling Salesman Problem, a search for the shortest path through a complicated itinerary of multiple cities. It touches on the Routing Problem, an even knottier optimization problem, which postulates how a fleet of vehicles might best deliver from a central depot. And because DoorDash was delivering food from multiple locations— with tight windows on freshness and a hungry customer waiting on the other end — there are problems that mathematicians have yet to name. “To make one delivery successful there’s fifteen small things you have to get correct, which is shocking,” says Xu.

Xu and his colleagues got a taste of how complicated this was even when they were making all the deliveries themselves. “The first version of the algorithm was my brain,” he says. “And I was like, Wow, this is really hard.” Of course, as the company moved to hundreds of deliveries from dozens of restaurants in a given market, hard became an understatement. One of their Stanford profs told them, “The problem you guys have has been theorized before but never solved.” No one had even collected the data to try and solve it.

But that’s exactly what DoorDash set out to do: gather a massive amount of data and then use machine learning to iterate to the best possible way to estimate delivery and execute it in a timely, mistake-free fashion. “We had to build a tech company,” he says. “Because if we’d tried to build an operations company, like FedEx or even Amazon, we would literally die trying.”

Hiring a team of engineers poached from Apple, Google and, yes, Amazon, DoorDash began building a system it called Deep Red, an homage to the IBM system that beat Garry Kasparov. “We’re trying to get it to do for local logistics what Deep Blue did in chess,” says co-founder and CTO Andy Fang, 23. It collects data on a secret number of “predictors” that contribute to an estimate of how long it takes to deliver the food. It works with partner apps to take into account conditions like traffic and weather. It crunches menus and ready times to determine which dishes take longer to prepare. It takes note of the efficiency of different Dashers. Then it takes note of its performance and what might have been right and wrong. With every order, Xu says, DoorDash gets smarter. And its next delivery might be better.

Recently, DoorDash hired Ding Zhou as VP of engineering, whose resume includes high posts at Klout and Facebook; most recently he was a director of engineering at Square. (At 33, he’s kind of the old man of the company.) “I’m very surprised at the quality of the system — beyond my expectations,” he says. “Obviously this is a very hard problem so there’s a lot of work to do. But this is how we will differentiate ourselves — to use all the data you can think of to measure every step of the delivery, to find the balance between efficiency and customer quality.”

So far, however, it’s sometimes hard to see how much that learning is actually reaching the Dashers. In the past couple of months of testing DoorDash, I’ve made multiple food orders to my home. Delivery people in my building must appear at the service entrance — if they go to the front door, they get bounced and must go through a process that can add ten extra minutes to the delivery time. This mistake was made several times — and since there are hundreds of people in my building, that misstep must have been repeated many more times. Yet the app never managed to alert Dashers to this twist. (DoorDash told me that the system doesn’t handle such details about customer location, though it does for the restaurants.)

Still, DoorDash seems to be pleasing customers — and impressing investors. In the Spring of 2014, DoorDash raised $17 million, largely from Sequoia, whose star VC Alfred Lin joined the board. A year later they got $40 million more, in a round led by Kleiner Perkins; that’s when Doerr became a director. (This combination may be known as the Google Double, reflecting the most famous parlay of those two venture giants.) At that point, the company was valued at $600 million.

Of course, DoorDash’s competitors are not as impressed as its funders. Its most direct rival — the Uber to its Lyft, or vice versa — is Postmates, a service that launched in 2011, two years before Tony Xu’s Accord delivered its first spring roll. Thus CEO and co-founder Bastien Lehmann refers to DoorDash as a “copycat.” Postmates originally began as a way to deliver bulky items like furniture. But it quickly realized that food delivery was the ideal category for a force of contract workers. Now, seventy percent of the sorties taken by Postmates (a term that seems oddly centerfoldish) involve prepared food. Some workers fill orders for both services, but Postmates also has deals with Apple, Starbucks and Chipotle to fulfill orders tapped into the apps of those companies. It wants to deliver everything.

So does DoorDash. Its first big non-food partner is 7-Eleven. More announcements are to come. Xu’s dream is to become the go-to service for all local merchants. And even some national ones. Asked if he’d work with Costco, he doesn’t hesitate.

“We’re open to it, right?”says Xu. “In order to truly build a delivery network in a city you have to be able to connect all the merchants to all the consumers.”

Co-founder Tang, 23, who holds the title of Chief Product Officer, says that the company’s broader ambitions are actually baked into the app’s visual design. Tang spent part of his childhood in Japan and commuted to school by bullet train, an experience that fascinated him. “It’s very modern, it’s super fast, it’s very efficient — and always on time. It’s also a utility, part of the fabric of Japanese society. People rely on it every single day.” That’s why he says the DoorDash app doesn’t scream food, but tries to convey a sense of speed and efficiency. “When people get DoorDash, we don’t want them to think about pizza,” he says. “We want them to think of all the qualities and values that are associated with the Japanese bullet train.”