2
$\begingroup$

What I am trying to do is for a diet app that I am planning to build. The goal is the users will input their desired macros (carbs, fat, protein) and the system should find all recipes that match the provided macros. It does not have to match it exactly, just the best match. Another idea is users provide their daily calorie intake and the system will find the best match, regardless of the macros.

Links and study materials are much appreciated.

$\endgroup$

closed as too broad by D.W. Mar 12 at 16:45

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ I don't see a clear problem specification here. You haven't told us what kinds of restrictions/constraints the macros can impose, nor how you want to measure which match is the best (i.e., how you want to measure how good a match each recipe is). Without that, I don't think this question is answerable; we're forced to guess what you might have in mind. Also, we require you to articulate a specific answerable question. "Links and study materials are much appreciated." is not a question. $\endgroup$ – D.W. Mar 12 at 16:45
0
$\begingroup$

Assuming you don't have that many recipes, you could just go over all of them and choose the best $k$ (use a heap of size $k$). You should test the naive approach before looking for fancier approaches.

Otherwise, you could use a data structure supporting nearest neighbor search. These are hard to implement, but good implementations should be available in computational geometry libraries.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.