I try the code below, is there a efficent way to do this?
c = []
l = [['A1','A2'], ['B1','B2'], ['C1','C2'] ]
for i in range(0, len(l) - 1):
for j in range(i+1, len(l)):
c.append(sorted([l[i][0],l[i][1],l[j][0]]))
c.append(sorted([l[i][0],l[i][1],l[j][1]]))
c.append(sorted([l[i][0],l[j][0],l[j][1]]))
c.append(sorted([l[i][1],l[j][0],l[j][1]]))
print(c)
Out put:
[['A1', 'A2', 'B1'], ['A1', 'A2', 'B2'], ['A1', 'B1', 'B2'],
['A2', 'B1', 'B2'], ['A1', 'A2', 'C1'], ['A1', 'A2', 'C2'],
['A1', 'C1', 'C2'], ['A2', 'C1', 'C2'], ['B1', 'B2', 'C1'],
['B1', 'B2', 'C2'], ['B1', 'C1', 'C2'], ['B2', 'C1', 'C2']