简体   繁体   中英

Possible permutation of variable length arrays in Python

I have 3 different product (A, B, C) to produce.
The quantities to produce are fix: A=3, B=3, C=2. So all together 8 products.
The problem is that I only have 2 preparation lines for 3 production lines each for a specific product: LineA, LineB, LineC.
The preparation lines can prepare all 3 type of products That means that I can only have 2 active production lines, the 3rd one is idle for that shift.
The duration of each working shift is equal.

So all together I'll have 4 working shifts (8 products / 2 preparation lines)

My question is: How can I write a algorithm which shows me all possible permutations. The output would be something similar to this (this is just one permutation, I'd need all possibilities to see the idle shifts) :

LineA LineB LineC
  A     B     -
  A     -     C
  -     B     C
  A     B     -

EDIT:
The actual lists for the above mentioned output are:

AAA
BBB
CC

EDIT2
The itertools functions are not working here as they are not taking into account the finite number of items in each list. I have a finite number of items so I need a list of list of all possible permutations/combination (in this example I would need n times of 4x3 matrix)
First I would need a first combination (like drawn in the example) than I would need all the possible combination of that.
Of course as the number is increasing there will be a bigger n for a ?x3 matrix
You can also forget the empty values, so in this case the result for the above mentioned example would be n times of a 4x2 matrix

If I am not overlooking something, the set of combinations A,B,C,- is constant. It is exactly those from your example. I cannot see a way to produce the numbers required any other way. So what you have to do is produce all permutations of the 4(3) production states you showed. If preparation lines are allowed to be idle, then things get markedly more interesting.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM