2

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?

QuantumDot
  • 19,601
  • 7
  • 45
  • 121

2 Answers2

3

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}}
Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
  • 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".
  • – QuantumDot Jun 11 '17 at 20:16
  • @QuantumDot It happens to all of us. :^) – Mr.Wizard Jun 11 '17 at 20:20