This problem is known as MINIMUM k-UNION, and it is NP-hard, as shown here:
So no-one knows any algorithm to solve it that runs in time that's polynomial in the size of the input.
In your case, you would probably be happy to accept an approximate solution: that is, a collection of recipes with a small union of ingredients, but not necessarily the very smallest such collection. So I suggest that you try the greedy algorithm: iteratively build up a collection of recipes by adding at each stage the recipe that minimizes the size of the union. Here's a na?ve implementation in Python:
def small_union(sets, k):
"""
Choose `k` elements from `sets` and return their union. Attempt
to return a fairly small union using a greedy approach.
>>> small_union([{1,2}, {2,3}, {1,2,3}, {1}, {2}], 3)
set([1, 2])
>>> small_union([{1,2}, {2,3}, {3,4}, {1,4}], 3)
set([1, 2, 3, 4])
"""
union = set()
for _ in xrange(k):
s = min(sets, key = lambda s: len(s | union))
sets.remove(s)
union |= s
return union
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…