Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as Python by loginblin ( 8 years ago )
a = [
[1, 2, 3, 10],
[4, 5, 6, 11],
[7, 8, 9, 12]
]
column_number = len(a[0])
row_number = len(a)
position_idx = [0 for _ in range(row_number)]
break_flag = False
permutations = list()
while (True):
tmp = list()
for row_idx, column_idx in enumerate(position_idx):
tmp.append(a[row_idx][column_idx])
permutations.append(tmp)
# Switch positions
position_idx[0] += 1
for i, idx_value in enumerate(position_idx):
if idx_value == column_number:
if i == row_number - 1:
break_flag = True
break
position_idx[i] = 0
position_idx[i + 1] += 1
if break_flag:
break
print(len(permutations))
for i in permutations:
print(i)
Revise this Paste