summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.com>2020-11-13 14:54:52 +0300
committerEvgeny Zinoviev <me@ch1p.com>2020-11-13 14:54:52 +0300
commite0efd6490e2172fc331985300ce362cf91a80201 (patch)
treeeda5b52034ec4e2aa11051ab5eafc1713337c8c2
initialHEADmaster
-rw-r--r--permute.py14
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)