Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>A deterministic solution (ie not random)</strong></p> <p>Sort your shows by decreasing number of episodes. </p> <p>Select the biggest and arrange a matrix with the number of columns corresponding to the number of episodes of this one, filled in the following way: </p> <pre><code>A A A A A A &lt;- First show consist of 6 episodes B B B B C C &lt;- Second and third show - 4 episodes each C C D D &lt;- Third show 2 episodes </code></pre> <p>Then collect by columns </p> <pre><code>{A,B,C}, {A,B,C}, {A,B,D}, {A,B,D}, {A,C}, {A,C} </code></pre> <p>Then Join</p> <pre><code>{A,B,C,A,B,C,A,B,D,A,B,D,A,C,A,C} </code></pre> <p>And now assign sequential numbers</p> <pre><code>{A1, B1, C1, A2, B2, C2, A3, B3, D1, A4, B4, D2, A5, C3, A6, C4} </code></pre> <p><strong>Edit</strong></p> <p>Your case</p> <pre><code>[['A'] * 2, ['L'] * 3, ['X'] * 5]) X X X X X L L L A A -&gt; {X1, L1, X2, L2, X3, L3, X4, A1, X5, A2} </code></pre> <p><strong>Edit 2</strong> </p> <p>As no Python here, perhaps a Mathematica code may be of some use: </p> <pre><code>l = {, , ,}; (* Prepare input *) l[[1]] = {a, a, a, a, a, a}; l[[2]] = {b, b, b, b}; l[[3]] = {c, c, c, c}; l[[4]] = {d, d}; le = Length@First@l; k = DeleteCases[ (*Make the matrix*) Flatten@Transpose@Partition[Flatten[l], le, le, 1, {Null}], Null]; Table[r[i] = 1, {i, k}]; (*init counters*) ReplaceAll[#, x_ :&gt; x[r[x]++]] &amp; /@ k (*assign numbers*) -&gt;{a[1], b[1], c[1], a[2], b[2], c[2], a[3], b[3], d[1], a[4], b[4], d[2], a[5], c[3], a[6], c[4]} </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload