# What’s the secret behind cleverlayover’s algorithm?

Cleverlayover is able to search more routes than any other site, and it finds cheaper flights than Kayak, Expedia, Orbitz and any other travel search engine. Cleverlayover compares all the possible ways to get from A to B, including all the possible ways to buy tickets from A to C to B. So what’s behind the cleverlayover algorithm? How does it compare so many routes with just one search?

The secret weapon is our resident mathematician and founder, Phil Hu. Phil has been performing academic research in advanced mathematics since the age of fourteen, and he was a nationally ranked competitive mathlete.

When a user on cleverlayover enters a search query, for example, “Boston to Sydney,” Phil opens up several hundred new tabs in Chrome and navigates to Kayak.com. He then enters a different search in each tab: “Boston to New York,” “New York to Sydney,” “Boston to London,” “London to Sydney,” “Boston to Honolulu,” “Honolulu to Sydney,” etc. until he exhaustively searches every possible airport in the world. There are 5000 of them. Using his mathematical genius, Phil performs the arithmetic necessary to add up the prices on each route. “Okay, so Boston to Honolulu is \$1251, and Honolulu to Sydney is \$460. Carry the 1, convert to hexadecimal, convert back to base 10, and we see that the total price of the ticket is \$1711.”

In a matter of seconds, Phil personally compares all possible routes using some mental gymnastics. Nevertheless, Phil admits that running cleverlayover is not as easy as it might first seem. “When two people search at once, I can get distracted and mix up the origins and destinations. I sometimes want to just ask people to wait their turn.”

There are also times when Chrome thinks there are too many open tabs. Chrome throws an error message that the tabs aren’t responding, forcing Phil to reload the tab. “Every second counts, and when I have to hit F5 or even Command + r on a Mac, that slows down the search for our users.”

Other times, Phil messes up the addition after a few drinks: “It just takes one or two Bud Lights, and all of a sudden our users are flying through North Korea to get from Boston to San Francisco.”

However, ultimately, Phil finds the experience extremely rewarding. “Of course I’ve considered writing a computer program to do this, or outsourcing the mental addition to workers not protected by minimum wage laws. But it’s that personal touch that our users appreciate, and I wouldn’t want to give that up.”