1

I'm working on a music related problem and I need some help with a crucial step.

I have four lists of numbers from 0 to 11 (including). These lists are to be thought of as vertically aligned. I want to partition those 4 lists into 4 blocks, each block containing all the numbers from 0 to 11, and each row of the block containing 0 to 11 elements from each list. An example:

l_1 = [0,1,4,9,5,8,3,10,2,11,6,7]
l_2 = [7,6,11,2,10,3,8,5,9,4,1,0]
l_3 = [0,11,8,3,7,4,9,2,10,1,6,5]
l_4 = [5,6,1,10,2,9,4,7,3,8,11,0]

A solution is to take elements from the beginning of each row and combining then. For example, a solution for partitioning this block is:

s = [(1,11),(1,2,9),(1,1,10),(2,10)]

The block would look like this:

p_1 = [[0],[1],[4,9,5,8,3,10,2,11,6,7],[]]
p_2 = [[7,6,11,2,10,3,8,5,9,4,1],[],[0],[]]
p_3 = [[],[0,11,8,3,7,4,9,2,10],[1],[6,5]]
p_4 = [[],[5,6],[],[1,10,2,9,4,7,3,8,11,0]]

Here, if we take the elements of same index on each p_list, we have a complete listing of the numbers from 0 to 11 (we can see this by looking at the lists vertically). For instance:

p_1[0] + p_2[0] + p_3[0] + p_4[0] = [0,7,6,11,2,10,3,8,5,9,4,1]

My problem is not to verify a solution, is to actually find one algorhitmically. That is, given 4 rows, how to find a sequence of partitions that is a solution to the problem. Since my background is mostly on music, I come to you for some assistance.

Thank you in advance!

EDIT: As pointed out below, there's also the [(12),(12),(12),(12)] solution. The goal here is to achieve as much diversity as possible of solutions, running this algorhithm through a large number of quartets of different rows.

  • 1
    Since empty lists are allowed, isn't there always going to be one trivial partition: `[l_1[0], [], [], []], [[], l_2[0], [], []], [[], [], l_3[], []],[[], [],[], l_4[]]`? What other constrain do you have that make this solution worse that some other? Are you optimizing for something? – Mark Feb 27 '22 at 18:37
  • Because I need to do this for a large number os lists and the goal is to achieve the maximum number of different solutions as possible. Sorry, I should have included this. – Pedro Proença Feb 27 '22 at 18:49
  • There are 34 partitions of the number 12 that have 4 or less parts. The goal is to try to find solutions that, when put together, use all (or as much as possible) of those 34 partitions. – Pedro Proença Feb 27 '22 at 18:50
  • 1
    Do you want multiple solutions for the same 4-list-group, or does "diversity of solutions" mean that a solution for a random 4-list-group should include partitions about uniformly randomly from the set of 34 possible partitions? – kcsquared Feb 27 '22 at 19:04
  • The ideal would be an algorithmic solution for any 4 list group. But those groups are chosen from a finite number of available lists. I didn't want to get into this, because it's more of a musical matter than an algorhithmic one. – Pedro Proença Feb 27 '22 at 19:17
  • 1
    And yes, multiple solutions for the same 4-list group would be helpful – Pedro Proença Feb 27 '22 at 19:17

0 Answers0