From e0efd6490e2172fc331985300ce362cf91a80201 Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Fri, 13 Nov 2020 14:54:52 +0300 Subject: initial --- permute.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 permute.py 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) -- cgit v1.2.3