diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2021-07-17 00:26:54 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-17 00:26:54 +0100 |
| commit | 0908914dd492436c49889de5272685c550b8e32e (patch) | |
| tree | d8644fc76bcd618bebfb4c299b17c97de830cc85 | |
| parent | 10efa0029dfcfbcc038a5e85052fd352c8387a03 (diff) | |
| parent | a66637f07937337ae048b18a4c8beadf4a82e887 (diff) | |
| download | perlweeklychallenge-club-0908914dd492436c49889de5272685c550b8e32e.tar.gz perlweeklychallenge-club-0908914dd492436c49889de5272685c550b8e32e.tar.bz2 perlweeklychallenge-club-0908914dd492436c49889de5272685c550b8e32e.zip | |
Merge pull request #4534 from stuart-little/stuart-little_072_lua
1st commit on 072_lua
| -rwxr-xr-x | challenge-072/stuart-little/lua/ch-1.lua | 14 | ||||
| -rwxr-xr-x | challenge-072/stuart-little/lua/ch-2.lua | 16 |
2 files changed, 30 insertions, 0 deletions
diff --git a/challenge-072/stuart-little/lua/ch-1.lua b/challenge-072/stuart-little/lua/ch-1.lua new file mode 100755 index 0000000000..0515cf6461 --- /dev/null +++ b/challenge-072/stuart-little/lua/ch-1.lua @@ -0,0 +1,14 @@ +#!/usr/bin/env lua + +-- run <script> <number> + +function factExp(n,p) + local s,frct=0,n/p + while frct >= 1 do + s=s+math.floor(frct) + frct=frct/p + end + return s +end + +print(math.min(factExp(arg[1],2),factExp(arg[1],5))) diff --git a/challenge-072/stuart-little/lua/ch-2.lua b/challenge-072/stuart-little/lua/ch-2.lua new file mode 100755 index 0000000000..9c7d4bb302 --- /dev/null +++ b/challenge-072/stuart-little/lua/ch-2.lua @@ -0,0 +1,16 @@ +#!/usr/bin/env lua + +-- run <script> <file 1st-line-nr 2nd-line-nr> + +function lnRng(pth,l1,l2) + local ix,lns=0,{} + for l in io.lines(pth) do + ix=ix+1 + if ix>=l1 and ix<=l2 then table.insert(lns,l) end + end + return lns +end + +for _,l in ipairs(lnRng(arg[1],tonumber(arg[2]),tonumber(arg[3]))) do + print(l) +end |
