-1
我從數據庫中獲取數據。從數據庫中他們在一個元組的形式:從元組創建組合
[('test1', 'test12', 'test13', 'test14'),
('test21', 'test22', 'test23', 'test24'),
('test31', 'test32', 'test33', 'test34'),
('test41', 'test42', 'test43', 'test44'),
('test51', 'test52', 'test53', 'test54'),
('test61', 'test62', 'test63', 'test64'),
('test71', 'test72', 'test73', 'test74'),
('test81', 'test82', 'test83', 'test84'),
('test91', 'test92', 'test93', 'test94'),
('test11', 'test12', 'test13', 'test14')]
而這正是我想要的: 使這些輸入的組合......所以輸出我有4個參數(如例子中)的組合和...
1)最重要的是,新的組合,值總是在它的位置,即如果在原始組合中的值是指數[1],這意味着在新的組合中,它應該也可以[1] ...
2)沒有重複的組合
作爲例子:
我得到的元組:
[('test91', 'test92', 'test93', 'test94'),
('test11', 'test12', 'test13', 'test14')]
而從這個我得到了新的組合:
[('test91', 'test12', 'test13', 'test14'),
('test11', 'test92', 'test93', 'test94')]
也許有可能使用做成對或其他方法。 幫助。
所以你要的所有的組合元組,這會很多。 –
是的,有很多可能的組合。 – Koushik
暴力方法:使用四個嵌套循環來捕獲所有可能的組合。有n^4種可能的組合(n是4元組數組的行數) – jrook