diff options
-rw-r--r-- | permute.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/permute.py b/permute.py new file mode 100644 index 0000000..f07de44 --- /dev/null +++ b/permute.py @@ -0,0 +1,14 @@ +def permute(xs, low=0): + if low + 1 >= len(xs): + yield xs + else: + for p in permute(xs, low + 1): + yield p + for i in range(low + 1, len(xs)): + xs[low], xs[i] = xs[i], xs[low] + for p in permute(xs, low + 1): + yield p + xs[low], xs[i] = xs[i], xs[low] + +for p in permute(list('whitelord')): + print ''.join(p) |