title: Maximum sum combinations from 4 arrays
body: <p>I have 4 arrays with 2 columns: one column measuring meters and the other measuring the money you get per meter, I want to get the highest sum combinations from these 4 arrays but I have 2 rules : the first rule is that each meter value in the sum has to be between 1 and 6 meters, and the second rule is that the meter value of the result has to be equal to 12 meters. I have written a code that gets the maximum sum out of a series of 4 arrays but I don't know how to implement the 2 rules in the code. This is why i am asking for your help.</p>
  <p>My 4 arrays :</p>
  <p>1,2,3,4,5,6 are the meter values
  and the numbers below the meter values is the money earned by meters</p>
  <pre><code>A = [[1, 2, 3, 4, 5, 6],
       [50.4, 100.8, 201.6, 403.2, 806.4, 1612.8]] 
  B = [[1, 2, 3, 4, 5, 6],
       [40.8, 81.6, 163.2, 326.4, 652.8, 1305.6]]
  C = [[1, 2, 3, 4, 5, 6],
       [110, 220, 440, 880, 1760, 3520]]
  D = [[1, 2, 3, 4, 5, 6],
       [64, 128, 256, 512, 1024, 2048]]
  </code></pre>
  <p>My code :</p>
  <pre><code>
  import math
  from queue import PriorityQueue
  def KMaxCombinations(A, B, C, D, N, K):
  
      # Max heap.
      pq = PriorityQueue()
  
      # Insert all the possible
      # combinations in max heap.
      for i in range(0,N):
          for j in range(0,N):
              for k in range(0,N):
                  for l in range(0,N):
                      a = A[i] + B[j] + C[k] + D[l]
                      pq.put((-a, a))
     
      # Pop first N elements from
      # max heap and display them.
      count = 0
      while (count &lt; K):
          print(pq.get()[1])
          count = count + 1
  
  
  # Driver method
  A = [50.4, 100.8, 201.6, 403.2, 806.4, 1612.8]
  B = [40.8, 81.6, 163.2, 326.4, 652.8, 1305.6]
  C = [110, 220, 440, 880, 1760, 3520]
  D = [64, 128, 256, 512, 1024, 2048]
  N = len(A)
  K = 3
  
  # Function call
  KMaxCombinations(A, B, C, D, N, K)
  
  </code></pre>