Created
February 4, 2017 08:39
-
-
Save akitotakeki/7439578d221ec54011797ec594f92f46 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
list(itertools.permutations('ABCD', 3)) | |
[('A', 'B', 'C'), | |
('A', 'B', 'D'), | |
('A', 'C', 'B'), | |
('A', 'C', 'D'), | |
('A', 'D', 'B'), | |
('A', 'D', 'C'), | |
('B', 'A', 'C'), | |
('B', 'A', 'D'), | |
('B', 'C', 'A'), | |
('B', 'C', 'D'), | |
('B', 'D', 'A'), | |
('B', 'D', 'C'), | |
('C', 'A', 'B'), | |
('C', 'A', 'D'), | |
('C', 'B', 'A'), | |
('C', 'B', 'D'), | |
('C', 'D', 'A'), | |
('C', 'D', 'B'), | |
('D', 'A', 'B'), | |
('D', 'A', 'C'), | |
('D', 'B', 'A'), | |
('D', 'B', 'C'), | |
('D', 'C', 'A'), | |
('D', 'C', 'B')] | |
seq = 'ABCD' | |
perm = ((x, y, z) for x in seq | |
for y in seq if y != x | |
for z in seq if z != x and z != y) | |
next(perm) | |
next(perm) | |
next(perm) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment