Created
July 11, 2012 02:08
-
-
Save sing1ee/3087500 to your computer and use it in GitHub Desktop.
permutation dfs
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
# !/usr/bin/python | |
# -*- encoding: utf-8 -*- | |
string_list = ['a', 'b', 'c', 'd', 'e'] | |
used = [0, 0, 0, 0, 0] | |
def dfs_permutation(permu, l): | |
if l == 3: | |
print permu | |
for i in range(len(string_list)): | |
if 0 == used[i]: | |
used[i] = 1 | |
dfs_permutation(permu + string_list[i], l + 1) | |
used[i] = 0 | |
dfs_permutation('', 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment