aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-110/stuart-little/lua/ch-1.lua13
-rwxr-xr-xchallenge-110/stuart-little/lua/ch-2.lua18
2 files changed, 31 insertions, 0 deletions
diff --git a/challenge-110/stuart-little/lua/ch-1.lua b/challenge-110/stuart-little/lua/ch-1.lua
new file mode 100755
index 0000000000..8444d9cd03
--- /dev/null
+++ b/challenge-110/stuart-little/lua/ch-1.lua
@@ -0,0 +1,13 @@
+#!/usr/bin/env lua
+
+-- run <script> <file>
+
+require('luarocks.loader')
+local re = require('re')
+
+for l in io.lines(arg[1]) do
+ local mtch = table.pack(re.match(l, "({'+'%d^2%s+%d^10 / '('%d^2')'%s+%d^10 / %d^4%s+%d^10/.})*"))
+ for _,v in ipairs(mtch) do
+ if v:len() > 1 then print(v) end
+ end
+end
diff --git a/challenge-110/stuart-little/lua/ch-2.lua b/challenge-110/stuart-little/lua/ch-2.lua
new file mode 100755
index 0000000000..1527844266
--- /dev/null
+++ b/challenge-110/stuart-little/lua/ch-2.lua
@@ -0,0 +1,18 @@
+#!/usr/bin/env lua
+
+-- run <script> <file>
+
+local t={}
+for l in io.lines(arg[1]) do
+ local lt = {}
+ for w in l:gmatch("[^,]+") do table.insert(lt,w) end
+ table.insert(t,lt)
+end
+
+for i=1,#t[1] do
+ local col = {}
+ for j=1,#t do
+ table.insert(col,t[j][i])
+ end
+ print(table.concat(col,","))
+end