Skip to content

Commit

Permalink
1st commit on 110_lua
Browse files Browse the repository at this point in the history
  • Loading branch information
stuart-little committed Jul 10, 2021
1 parent 091011a commit 1132917
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
13 changes: 13 additions & 0 deletions 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
18 changes: 18 additions & 0 deletions 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

0 comments on commit 1132917

Please sign in to comment.