I got a problem and I only got a time consuming solution.
I got a array with recipes including total calories. Now I want to create a daily menu with lets say 1500 calories max.
However I want to get as close to the 1500 as possible.
Now there is an array for breakfast, lunch and dinner.
My solution for now is start with breakfast and then add the highest calorie lunch and then starting to add dinner recipes untill it fits. If I get over the 1500 with each I take the next lunch recipe and go again with the dinner recipes and so on. This seems timeconsuming to me. Anyone got another solution idea?
I don't want to recompile the daily menus and do it on the fly. However this will be done by a cgi application once a day.
Array Calculation Problems
Moderator: General Moderators
Re: Array Calculation Problems
Without getting into the other algorythmic issues I'll offer something relating to the above quote. If you don't want to do all this calculating on a daily basis, don't. Why not run through each possilbe combination and only store those that are acceptable in a look up table of sorts. If you later add a new dish at say breakfast or dinner, run a script or program to recompute the entire thing.AGISB wrote: I don't want to recompile the daily menus and do it on the fly. However this will be done by a cgi application once a day.