fork download
  1. import itertools
  2. line = ['A','B','%']
  3. def line_permutations(line):
  4. if '%' not in line:
  5. return [line]
  6. line.remove('%') # use copy.copy if you don't want to modify your matrix here
  7. for i in range(len(line)):
  8. yield line[i:] + ['%'] + line[:i]
  9. permutations = itertools.product([line_permutations(line) for line in matrix])
  10. print(permutations)
Runtime error #stdin #stdout 0.02s 5852KB
stdin
Standard input is empty
stdout
Standard output is empty