private static void Test(int[] protein, int[] carbs, int[] fat, string[] dietPlans, int[] expected) { var result = MealSelector.SelectMeals(protein, carbs, fat, dietPlans).SequenceEqual(expected) ? "PASS" : "FAIL"; Console.WriteLine($"Proteins = [{string.Join(", ", protein)}]"); Console.WriteLine($"Carbs = [{string.Join(", ", carbs)}]"); Console.WriteLine($"Fats = [{string.Join(", ", fat)}]"); Console.WriteLine($"Diet plan = [{string.Join(", ", dietPlans)}]"); Console.WriteLine(result); }
public static int[] SelectMeals(int[] protein, int[] carbs, int[] fat, string[] dietPlans) { var meals = new List <Meal>(); for (int i = 0; i < protein.Length; i++) { meals.Add(new Meal(i, protein[i], carbs[i], fat[i])); } var mealSelector = new MealSelector(meals); var mealSelections = new int[dietPlans.Length]; for (int i = 0; i < dietPlans.Length; i++) { var dietPlan = dietPlans[i]; var meal = mealSelector.GetPreferredMeal(dietPlan); mealSelections[i] = meal.Id; } return(mealSelections); }