I am unsure if I have even identified the problem correctly, but reading up on knapsack problem seems the closest to what I am trying to solve:
A cook has $k$ ingredients of $p$ quantities. Given a list of $n$ unique recipes, each consisting varying ingredients of varying quantities. Now, the cook would like to use all ingredients on ONE recipe with minimal leftovers.
What is his solution? And can it be determined in $O(\log n)$ time?
Sample input
500 pounds of flour 300 mg sugar 5 mg of vanilla pods 20 eggs
Database of possible recipes:
Thai Fried Noodles (doesn't contain vanilla or flour, but contains 1 tablespoon of sugar)
Tiramisu (doesn't contain flour and vanilla but contains 3 tablespoons of sugar and 8 eggs)
Anna's Special Tiramiu (doesn't contain flour and vanilla but contains 1 tablespoons of sugar and 8 eggs)
Truffle Tagliatelle (doesn't contain any input ingredients)
EDIT Cost/benefit decision:
Given the sample input, Tiramisu recipe is the most preferred because among the 4 recipes in the database, it contains the most number of input ingredient type (2 of 4 types), and the most number of input ingredient quantity.
Expected result where 1) is the top search result of relevance: 1) Tiramisu 2) Anna's Special Tiramisu 3) Thai Fried Noodles 4) Truffle Tagliatelle
EDIT: I believe my question is a variant of the integer knapsack problem