Weighted random selection,
ou are given a list of recipes. Each recipe may require some ingredients, and some of those ingredients might themselves be other recipes.
You are also given a list of supplies that you already have.
A recipe can be prepared only if all its required ingredients are available — either from the initial supplies or by preparing other recipes.
Your task is to return all the recipes that can eventually be prepared.
Example:
Recipes = ["bread", "sandwich", "burger"]
Ingredients = [
["flour", "water"], // bread
["bread", "ham"], // sandwich
["sandwich", "bread"] // burger
]
Supplies = ["flour", "water", "ham"]
Output:
["bread", "sandwich", "burger"