# Find all permutations with a condition (part 2) [closed]

This question (21008) asks to find all permutations of {a, b, c} subject to a + b + c = n. The answer was provided by Dr. belisarius using IntegerPartitions.

How can we generalize that answer to find all permutations of {a, b, c} subject to 2 a + b + c = const, or more generally find all partitions subject to {a, b, c, d, e, ...} subject to 2 a + b + c + d + e + ... = n?

Are you looking for FrobeniusSolve? e.g. for $2 a + b + c = 5$

FrobeniusSolve[{2, 1, 1}, 5]

{{0, 0, 5}, {0, 1, 4}, {0, 2, 3}, {0, 3, 2}, {0, 4, 1}, {0, 5, 0},
{1, 0, 3},  {1, 1, 2}, {1, 2, 1}, {1, 3, 0}, {2, 0, 1}, {2, 1, 0}}

• * facepalm! * If the answer is that simple, then the best thing to do is to accept this answer, and close this question because "it can easily be found in the documentation". Jun 11 '17 at 20:16
• @QuantumDot It happens to all of us. :^) Jun 11 '17 at 20:20

g[sz_, n_] := Partition[Flatten[Map[Thread[{

where f is defined in the question you mentioned:
f[sum_, quant_] := Flatten[Permutations /@