aboutsummaryrefslogtreecommitdiff
path: root/challenge-112/stuart-little/lua/ch-2.lua
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-112/stuart-little/lua/ch-2.lua')
-rwxr-xr-xchallenge-112/stuart-little/lua/ch-2.lua25
1 files changed, 25 insertions, 0 deletions
diff --git a/challenge-112/stuart-little/lua/ch-2.lua b/challenge-112/stuart-little/lua/ch-2.lua
new file mode 100755
index 0000000000..2c5374463b
--- /dev/null
+++ b/challenge-112/stuart-little/lua/ch-2.lua
@@ -0,0 +1,25 @@
+#!/usr/bin/env lua
+
+-- run <script> <number>
+
+local memo={[0]={{}},{{1}},{{1,1},{2}}}
+
+function pths(n)
+ if n >= #memo then
+ table.insert(memo,{})
+ for i = 1,2 do
+ for _,pth in ipairs(memo[n-i]) do
+ table.insert(memo[n],table.pack(i,table.unpack(pth)))
+ end
+ end
+ end
+ return memo[n]
+end
+
+for i = 3,arg[1] do
+ pths(i)
+end
+
+for _,pth in ipairs(memo[tonumber(arg[1])]) do
+ print(table.unpack(pth))
+end