title: Calculate cheapest shopping basket
body: <p>Given a products table:</p>
  
  <pre><code>Products
  ID | Name | PriceCents
  </code></pre>
  
  <p>And <code>bundles</code> which are collections of products which when bought together give a discount:</p>
  
  <pre><code>Bundles
  ID | Name
  
  BundleItem
  BundleID | ItemID | QuantityRequired | DiscountPercent
  </code></pre>
  
  <p>Given a collection of item ID's and quantities in your <code>basket</code>, how do you calculate which bundles offer the best price for the customer?</p>
  
  <p>I am thinking the only way to do this is brute force all combinations, but it doesn't seem very elegant.</p>
  
  <p>As bundles can be user generated, there can be lots of them, and there could exist two bundles with the same items but with different discounts.</p>