aboutsummaryrefslogtreecommitdiff
path: root/challenge-117/stuart-little/python/ch-2.py
diff options
context:
space:
mode:
authorchirvasitua <stuart-little@users.noreply.github.com>2021-06-14 13:13:07 -0400
committerchirvasitua <stuart-little@users.noreply.github.com>2021-06-14 13:13:07 -0400
commitb3e0d81b91d18703ea0453fde48dbe396159af22 (patch)
tree3a6f61add6f3d220be7a2e1be31450169086d127 /challenge-117/stuart-little/python/ch-2.py
parentdad6bcabbefc743b091695a82fcfb92342397e38 (diff)
downloadperlweeklychallenge-club-b3e0d81b91d18703ea0453fde48dbe396159af22.tar.gz
perlweeklychallenge-club-b3e0d81b91d18703ea0453fde48dbe396159af22.tar.bz2
perlweeklychallenge-club-b3e0d81b91d18703ea0453fde48dbe396159af22.zip
1st commit on 117_python
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)