I have following pairs:
pairs = [(1,9),(5,5),(6,4),(2,8)]
From the pair I can take only one element. I need to generate n lists of binary mask combinations with minimal sum, where 0 for first element and 1 for second.
Output of provided example if n == 5:
[0,0,1,0], [0,1,1,0], [0,0,0,0], [0,1,0,0], [0,0,1,1]
Is it kind of Knapsack Problem? What is the best algorithm for doing this?