Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find recipes that can be cooked from provided ingridients [closed]

Tags:

algorithm

Sorry for bad English :(

Suppose i can preliminary organize recipes and ingredients data in any way.
How can i effectively conduct search of recipes by user-provided ingredients, preferably sorted by max match - so, first going recipes that use maximum of provided ingridients and do not contain any other ingrs, after them recipes that uses less of provided set and still not any other ingrs, after them recipes with minimum additional requirements and so on?

All i can think about is represent recipe ingridients like bitmasks, and compare required bitmask with all recipes, but it is obviously a bad way to go.

And related things like Levenstein distance i don't see how to use here.

I believe it should be quite common task...

like image 281
skaurus Avatar asked Apr 19 '10 13:04

skaurus


People also ask

Is there an app that tells you what you can cook with the ingredients you have?

SuperCook is one of the best ways to reduce food waste in the home. It finds recipes that use as many of your ingredients as possible, so nothing goes to waste. SuperCook makes food waste prevention fun and easy, just open the menu page on the app and choose a recipe.

Is there a website where you can put in ingredients and get recipes?

: SuperCook allows you to start by selecting ingredients you already have on hand from several categories (dairy, seasoning, soup and more). When you add available ingredients, SuperCook suggests recipes, updating results for each new item you include.

Can you get a recipe from a restaurant?

A: Chefs and restaurants are used to getting recipe requests these days and will typically comply with pleasure. It will help if you can be specific, perhaps in a follow-up email, with how many servings you're interested in.


1 Answers

It sounds like you're talking about sets - "available ingredients" is one set, and you want to find all recipes whose ingredients form a subset of that, ordered by size. Sets are efficiently implemented as balanced trees or hashtables.

It gets a bit more complicated when you want to address different amounts of ingredients.

Edit: If your recipe data is stored in an SQL database, it should actually be possible to do the the whole thing efficiently as an SQL query (which will use hastables and trees internally). But it's going to be a pretty complex query; better ask someone who's better at SQL than me (and of course your actual table structre is necessary).

like image 132
Michael Borgwardt Avatar answered Oct 23 '22 11:10

Michael Borgwardt