Bundles Within Budget
Hard · Iterators
itertools.combinations(items, 2) yields every unordered pair exactly once, in input order: for [a, b, c] you get (a, b), (a, c), (b, c).
A gift shop wants to suggest two-item bundles. Write pairs_within_budget(items, budget), where items is a list of [name, price] pairs with whole-number prices.
Return a line "<name1> + <name2> = <total>" for every pair whose total is at most budget, sorted by total from low to high. Pairs with the same total keep the order in which combinations produces them (Python's sort is stable).
Next: CSV Totals per Category