From Thundering Hog, 2 Weeks ago, written in Python.
This paste is a reply to Untitled from Subtle Gorilla - view diff
  1. import random
  2.  
  3. meals_dict = {
  4.    'Sample Dish 1': {
  5.                'Chicken Breasts': 2,
  6.                'Green Pepper': 1,
  7.                'Mushrooms Grams': 125
  8.    },      
  9.        
  10.    'Sample Dish 2': {
  11.            'Tomato': 2,
  12.            'Spaghetti Grams': 250
  13.    },
  14.  
  15.    'Sample Dish 3': {
  16.             'Steaks': 2,
  17.             'Potatoes': 4
  18.    },
  19.        
  20.    'Sample Dish 4': {
  21.             'Chicken Breasts': 4,
  22.             'Breadcrumbs Grams': 100,
  23.             'Parmesan Grams': 50,
  24.             'Mozarella': 1,
  25.             'Tomato Puree Sachet': 1
  26.    },
  27.  
  28.    'Sample Dish 5': {
  29.             'Mince Grams': 250,
  30.             'Onion': 1,
  31.             'Beef Stock Cube': 1,
  32.             'Carrot': 1,
  33.             'Tomato Puree Sachet': 1
  34.    },
  35.  
  36.       'Sample Dish 6': {
  37.             'Cheese Grams': 10,
  38.             'Milk ml': 400,
  39.             'Macaroni Grams': 250
  40.    },
  41.       'Sample Dish 7': {
  42.             'Rice Grams': 100,
  43.             'Chicken Pieces': 2,
  44.             'Soup Packet': 1
  45.    },
  46. }
  47.  
  48. shopping_list = {}
  49.  
  50. for meal, ingredients in dict(random.sample(meals_dict.items(), 7)).items():
  51.      print(f'Meal: {meal}')
  52.      for ingredient, qty in ingredients.items():
  53.         print(f'  require: {ingredient} x {qty}')
  54.         shopping_list[ingredient] = shopping_list.get(ingredient, 0) + qty
  55. print('-------------')
  56. print('Shopping List')
  57. print('-------------')
  58. for ingredient, qty in sorted(shopping_list.items()):
  59.    print(f'{ingredient} x {qty}')
captcha