-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Sample data structure for recipes | ||
recipes = { | ||
"Spaghetti Bolognese": { | ||
"ingredients": ["spaghetti", "ground beef", "tomato sauce", "onion", "garlic"], | ||
"dietary_restrictions": ["none"], | ||
"meal_type": "dinner" | ||
}, | ||
"Chicken Salad": { | ||
"ingredients": ["chicken breast", "lettuce", "tomatoes", "cucumber", "olive oil", "lemon"], | ||
"dietary_restrictions": ["gluten-free", "dairy-free"], | ||
"meal_type": "lunch" | ||
}, | ||
"Vegetable Stir Fry": { | ||
"ingredients": ["bell peppers", "broccoli", "carrot", "soy sauce", "ginger", "garlic"], | ||
"dietary_restrictions": ["vegan", "gluten-free"], | ||
"meal_type": "dinner" | ||
}, | ||
"Pancakes": { | ||
"ingredients": ["flour", "milk", "eggs", "sugar", "baking powder", "butter"], | ||
"dietary_restrictions": ["vegetarian"], | ||
"meal_type": "breakfast" | ||
} | ||
} | ||
|
||
def get_user_preferences(): | ||
dietary_restrictions = input("Enter your dietary restrictions (comma-separated, e.g., gluten-free, vegan): ").split(",") | ||
available_ingredients = input("Enter available ingredients (comma-separated): ").split(",") | ||
meal_type = input("What type of meal are you looking for (breakfast, lunch, dinner)? ").strip().lower() | ||
|
||
return [restriction.strip() for restriction in dietary_restrictions], \ | ||
[ingredient.strip() for ingredient in available_ingredients], \ | ||
meal_type | ||
|
||
def recommend_recipes(dietary_restrictions, available_ingredients, meal_type): | ||
recommendations = [] | ||
|
||
for recipe, details in recipes.items(): | ||
# Check for dietary restrictions | ||
if any(restriction in details["dietary_restrictions"] for restriction in dietary_restrictions): | ||
continue | ||
|
||
# Check if the recipe can be made with available ingredients | ||
if all(ingredient in available_ingredients for ingredient in details["ingredients"]): | ||
# Check for meal type | ||
if details["meal_type"] == meal_type: | ||
recommendations.append(recipe) | ||
|
||
return recommendations | ||
|
||
# Main program | ||
def main(): | ||
print("Welcome to the Personalized Recipe Recommendation System!") | ||
dietary_restrictions, available_ingredients, meal_type = get_user_preferences() | ||
|
||
recommended_recipes = recommend_recipes(dietary_restrictions, available_ingredients, meal_type) | ||
|
||
if recommended_recipes: | ||
print("\nRecommended Recipes:") | ||
for recipe in recommended_recipes: | ||
print(f"- {recipe}") | ||
else: | ||
print("\nNo recipes found that match your preferences.") | ||
|
||
if __name__ == "__main__": | ||
main() |