Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
例えば:
次の配列があるとします。
[1,2,3] [4,5,6] [7,8,9]
そして、この配列を生成したい:
[1,5,9] [1,6,8] [4,2,9] [4,8,3] [7,2,6] [7,5,3]
import itertools A=[[1,2,3], [4,5,6], [7,8,9]] for P in itertools.permutations(range(len(A))): print [A[p][i] for i,p in enumerate(P)]
版画:
[1, 5, 9] [1, 8, 6] [4, 2, 9] [4, 8, 3] [7, 2, 6] [7, 5, 3]