aboutsummaryrefslogtreecommitdiff
path: root/challenge-117/stuart-little/python/ch-2.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-117/stuart-little/python/ch-2.py')
-rwxr-xr-xchallenge-117/stuart-little/python/ch-2.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/challenge-117/stuart-little/python/ch-2.py b/challenge-117/stuart-little/python/ch-2.py
new file mode 100755
index 0000000000..89971728a9
--- /dev/null
+++ b/challenge-117/stuart-little/python/ch-2.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+
+# run <script> <number>
+
+import sys
+
+memo=[[''],['R','LH']]
+
+def mkPaths(size):
+ if size >= len(memo):
+ res = ['R' + x for x in mkPaths(size-1)]
+ res += ['L' + lft + 'H' + rght for nr in range(size) for lft in mkPaths(nr) for rght in mkPaths(size-1-nr)]
+ memo.append(res)
+ return memo[size]
+
+for pth in mkPaths(int(sys.argv[1])):
+ print(pth)