Created
November 18, 2018 23:42
-
-
Save mofas/041df2b78c222ab58e4d705c44feba05 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
seq = ['A', 'B', 'C'] | |
current = [] | |
next = [] | |
for char in seq: | |
for c in current: | |
next.append(c + char) | |
next.append(char + c) | |
next.append(char) | |
current = current + next | |
next = [] | |
print(current) | |
# ['A', 'AB', 'BA', 'B', 'AC', 'CA', 'ABC', 'CAB', 'BAC', 'CBA', 'BC', 'CB', 'C'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment