final version of the diet problem