There's an app for that : finding an optimal gas station?

Has anyone ever written an app that uses a database like Gas Buddy and calculates the optimal gas station to travel to?

It would factor in the fuel efficiency of your car for the round trip between you and potential gas stations, and the value of your time, and then calculate which station is the best alternative. The algorithm wouldn’t be as expensive to compute as sounds : any stations that have the same price as a previously considered station but are farther away don’t even have to be considered.