I am working on a problem where I have to generate a table of components while each component of the table has 18 entries. Six of the indices among 18 run from 0 to 1 while the other 12 can take values between 0 to 3. After doing that I have to select some of the entries which follow a certain criterion (sum of all values in each component should be three). I have done this for smaller sized entry tables but for this one Mathematica gives up very fast saying General::nomem: The current computation was aborted because there was insufficient memory available to complete the computation
. I don't have a larger memory computer available. Can somebody help me with this please? The commands I am using are:
list =
Table[{i, j, k, l, m, n, o, p, q, r, s, u, v, x, y, z, a, b},
{i, 0, 1}, {j, 0, 3}, {k, 0, 3}, {l, 0, 1}, {m, 0, 3}, {n, 0, 3}, {o, 0, 1},
{p, 0, 3}, {q, 0, 3}, {r, 0, 1}, {s, 0, 3}, {u, 0, 3}, {v, 0, 1}, {x, 0, 3},
{y, 0, 3}, {z, 0, 1}, {a, 0, 3}, {b, 0, 3}] // Flatten
list1 = Partition[%, 18];
f1 = Total[#] < 4 &;
f2 = Total[#] > 2 &;
list2 = Select[list1, f1];
list3 = Select[list1, f2];
list4 = Intersection[list2, list3];
p1 = Join @@ Permutations /@ IntegerPartitions[3, {18}, Range[0, 3]]; result = Cases[p1, Alternatives @@@ Range[0, {1, 3, 3, 1, 3, 3, 1, 3, 3, 1, 3, 3, 1, 3, 3, 1, 3, 3}]];
? $\endgroup$