aboutsummaryrefslogtreecommitdiff
path: root/challenge-085/stuart-little/lua/ch-1.lua
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2021-07-17 00:26:19 +0100
committerGitHub <noreply@github.com>2021-07-17 00:26:19 +0100
commit10efa0029dfcfbcc038a5e85052fd352c8387a03 (patch)
treee5c13edb19e9b7346043457dc57c0e86c502ea78 /challenge-085/stuart-little/lua/ch-1.lua
parent1eec60b6cab6562a5eef76a369c0abe704d45f82 (diff)
parentd9cb00dab85f052c8df9c09030e661fb01fae4d5 (diff)
downloadperlweeklychallenge-club-10efa0029dfcfbcc038a5e85052fd352c8387a03.tar.gz
perlweeklychallenge-club-10efa0029dfcfbcc038a5e85052fd352c8387a03.tar.bz2
perlweeklychallenge-club-10efa0029dfcfbcc038a5e85052fd352c8387a03.zip
Merge pull request #4533 from stuart-little/stuart-little_085_lua
1st commit on 085_lua
Diffstat (limited to 'challenge-085/stuart-little/lua/ch-1.lua')
-rwxr-xr-xchallenge-085/stuart-little/lua/ch-1.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/challenge-085/stuart-little/lua/ch-1.lua b/challenge-085/stuart-little/lua/ch-1.lua
new file mode 100755
index 0000000000..3188432ec2
--- /dev/null
+++ b/challenge-085/stuart-little/lua/ch-1.lua
@@ -0,0 +1,22 @@
+#!/usr/bin/env lua
+
+-- run <script> <space-separated numbers>
+
+local nrs={}
+for _,v in ipairs(arg) do
+ local nr=tonumber(v)
+ if nr<2 then table.insert(nrs,nr) end
+end
+table.sort(nrs)
+for i=1,#nrs-2 do
+ for j=i+1,#nrs-1 do
+ for k=j+1,#nrs do
+ local s=nrs[i]+nrs[j]+nrs[k]
+ if s>1 and s<2 then
+ print(1)
+ os.exit()
+ end
+ end
+ end
+end
+print(0)