title: How to find which combinations of my list of lists gives me the maximum average from a dictionary
body: <p>I have a Dictionary <code>D</code> and a list of lists <code>D_best</code>. 
  I want to find which combinations of my list gives me the maximum average from dictionary values. </p>
  
  <pre><code>D = {'Discount': {'D1': 15, 'D2': 26, 'D3': 19, 'D4': 14, 'D5': 20, 'D6': 42}}
  
  D_best = [['D1', 'D6'], ['D3', 'D1']]
  </code></pre>
  
  <p>Combination1 = 57 <code>D1 + D6</code></p>
  
  <p>Combination2 = 34 <code>D1 + D3</code></p>
  
  <pre><code>max(Combination1, Combination2)
  </code></pre>
  
  <p>retrun the best combination is <code>[D1, D6]</code></p>
  
  <p><strong>Constraints :</strong> </p>
  
  <ol>
  <li>I need to pick the best one from the D_best</li>
  <li>D_best contains any number of elements in it, here in example shown are 2 i.e.,<code>len(D_best)</code></li>
  <li>length of each element within <code>D_best</code> would remain constant. For example <code>len(D_best[0])</code> will be same as <code>len(D_best[1])</code></li>
  </ol>
  
  <p>I have been trying this way: </p>
  
  <pre><code>D = {'Discount': {'D1': 15, 'D2': 26, 'D3': 19, 'D4': 14, 'D5': 20, 'D6': 42}}
  
  D_best = [['D1', 'D6'], ['D3', 'D1']]
  
  Dlist3 = []
  for i in D_best:
      for j in i:
          Dlist3.append(j)
  Dlist3 = set(Dlist3)  
  
  disc_dict = {}
  for i in Dlist3:
      disc_dict[i] = D['Discount'][i]
  
  print(disc_dict)
  
  c ={}
  for n,i in enumerate(D_best):
      ck = ("c{}".format(n))
      c[ck] = i
  print(c)
  
  {'D3': 19, 'D1': 15, 'D6': 42}
  {'c1': ['D3', 'D1'], 'c0': ['D1', 'D6']}
  </code></pre>
  
  <p>`</p>