Optimize Fourthmeal: Tacos, Knapsacks and Webhooks

Posted on

We have all wondered how to get the most bang for your buck while shopping. The constraint is most commonly your budget, which could be currency, capacity or even calories. You also want to optimize for value. Fortunately, computer scientists have a way of solving these problems with the knapsack algorithm. That’s exactly what I used at the recent TechCrunch Disrupt Hackathon to fit the most food I could into a Taco Bell order based on the amount of money available. In this post, I’ll tell you exactly how I did it.

Let’s be honest. What people really want to optimize is their budget at Taco Bell. There are so many menu combinations you can order, but which combo will really give you the best bang for your buck?

I Don't Always Eat at Taco Bell...

The Inbound Parse Webhook makes this information super easy to get no matter where you are. Just email your budget (i.e: $4.39) in the subject to tacobell@sendmail.io. The app will reply back to you with a menu that gives you the most value for your budget. In this case, we define value as caloric intake. The app also uses the 0-1 variant of the knapsack problem to optimize for variety. This means we don’t repeat menu items because that just gets boring.

Taco Bell email reply

All the code is on GitHub, so you can see the details behind how I created this hack. You can also try creating your own variation. Perhaps try to optimize the drinks you can buy to get the most for your dollar. Or, instead of making your budget consist of currency, make it calories–that is, see how many items you can purchase with eating the least amount of calories.

For more on the Parse Webhook, check out my webcast Be an Email Switch Hitter, then be sure to let me know what you build. I’d love to feature it on the SendGrid blog.

Meet Kunal, Developer Evangelist at-large for SendGrid and home-grown New Jersey hacker. He previously ran General Machines, which developed Deaftel - a phone service for the deaf that converts voice to text and text back into voice over a phone call. Since March 2013, Kunal has been working as a Developer Evangelist at SendGrid, helping enable developers to get the tools and resources they need to make awesome, creative stuff.

Kunal Batra on Twitter
Have thoughts on this post?
Chat with us about it on Twitter and Google+