Array Calculation Problems
Posted: Mon Jan 02, 2006 7:09 am
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.
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.