Optimize Fourthmeal: Tacos, Knapsacks and Webhooks
SendGrid TeamWe 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?
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.
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.