title: Shopping cart minimization algorithm
body: <p>I have a list of <code>products</code>, which consists of list of <code>shops</code>, which sold it. </p>
  
  <pre><code>{
      'Book A': [ShopA, ShopB, ShopC],
      'Book B': [ShopC, ShopD],
      'Movie C': [ShopA, ShopB, ShopD, ShopE],
      ...
  }
  </code></pre>
  
  <p>(Price differs between the shops)</p>
  
  <p>Each shop is also has a shipping cost. It's a "per-order" shipping cost, it doesn't matter how many items are in my cart. And it differs between the shops too.</p>
  
  <p><em>Ex: if I buy "Book A" from ShopA, "Book B" from ShopC and "Movie C" from ShopA, the resulting price is: <code>Book A price in ShopA</code> + <code>Book B price in ShopC</code> + <code>Movie C price in ShopA</code> + <code>ShopC shipping cost</code> + <code>ShopA shipping cost</code></em></p>
  
  <p>If the shipping cost was zero or it was on per-item basis and constant, than I would just sort the offer lists by <code>price+shipping</code> field and fetch the first result from each set.</p>
  
  <p>I need to buy <strong>all</strong> the items <strong>once</strong> and find the minimal price <strong>and</strong> the resulting set.</p>
  
  <p>I'm not very good with optimization algorithms and dynamic programming so I need a solution or just a nod into the right direction.</p>