0

Given a list K of groups of items, each group possessing some fixed number of items, what would be a time efficient algorithm to generate all (full) permutations of items from said groups?

Example: If K = {A:3, B:2, C:4}, then these are three valid permutations:

AAABBCCCC
ABACCBCCA
CBACCBCAA

There seems to be some relation to Gray code, but with the added weights I'm not sure how to extend it. Trying to do better than monotonously increasing the overall permutation value and resetting on each iteration.

SBM
  • 40
  • 6
  • duplicate of: https://stackoverflow.com/questions/19676109/how-to-generate-all-the-permutations-of-a-multiset – One Lyner May 10 '20 at 14:46

1 Answers1

0

You can have a look at "13.2 Permutations of a multiset" here https://jjj.de/fxt/fxtbook.pdf

One Lyner
  • 1,964
  • 1
  • 6
  • 8