diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2021-07-14 03:19:02 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-14 03:19:02 +0100 |
| commit | ba46beae958e10782919af2d5fe3b0d8d7c55a60 (patch) | |
| tree | 7701309585b7320265ad95727333bb0d5995224a | |
| parent | c377c217590eaed53dde1ad03d9b80aa3c172429 (diff) | |
| parent | e0e7fb624169e117aed81df17e5ef4182b1a2a84 (diff) | |
| download | perlweeklychallenge-club-ba46beae958e10782919af2d5fe3b0d8d7c55a60.tar.gz perlweeklychallenge-club-ba46beae958e10782919af2d5fe3b0d8d7c55a60.tar.bz2 perlweeklychallenge-club-ba46beae958e10782919af2d5fe3b0d8d7c55a60.zip | |
Merge pull request #4513 from stuart-little/stuart-little_082_lua
1st commit on 082_lua
| -rwxr-xr-x | challenge-082/stuart-little/lua/ch-1.lua | 7 | ||||
| -rwxr-xr-x | challenge-082/stuart-little/lua/ch-2.lua | 11 |
2 files changed, 18 insertions, 0 deletions
diff --git a/challenge-082/stuart-little/lua/ch-1.lua b/challenge-082/stuart-little/lua/ch-1.lua new file mode 100755 index 0000000000..5671895075 --- /dev/null +++ b/challenge-082/stuart-little/lua/ch-1.lua @@ -0,0 +1,7 @@ +#!/usr/bin/env lua + +-- run <script> <space-separated numbers> + +for i=1,math.min(tonumber(arg[1]),tonumber(arg[2])) do + if (tonumber(arg[1]) % i == 0) and (tonumber(arg[2]) % i == 0) then print(i) end +end diff --git a/challenge-082/stuart-little/lua/ch-2.lua b/challenge-082/stuart-little/lua/ch-2.lua new file mode 100755 index 0000000000..07b1a448f6 --- /dev/null +++ b/challenge-082/stuart-little/lua/ch-2.lua @@ -0,0 +1,11 @@ +#!/usr/bin/env lua + +-- run <script> <space-separated strings, with the target string last> + +function canInterleave(a,b,c) + if math.max(a:len(),b:len(),c:len()) == 0 then return true end + if a:sub(1,1) == c:sub(1,1) then return canInterleave(a:sub(2),b,c:sub(2)) end + if b:sub(1,1) == c:sub(1,1) then return canInterleave(a,b:sub(2),c:sub(2)) end + return false +end +print(canInterleave(table.unpack(arg,1,3)) and 1 or 0) |
