aboutsummaryrefslogtreecommitdiff
path: root/challenge-096/tyler-wardhaugh/lua/ch-1.lua
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2021-01-21 01:54:35 +0000
committerGitHub <noreply@github.com>2021-01-21 01:54:35 +0000
commit878d7ba2b2e95df8d0d59caa63019c1ac8cd198f (patch)
tree8335b89b59173681dc8ee0fe75c74fd79824861c /challenge-096/tyler-wardhaugh/lua/ch-1.lua
parent56877338c2addcd41e2a8685b205f505963827b2 (diff)
parentd803b8295cb052657601c0f90392afac7b5fde47 (diff)
downloadperlweeklychallenge-club-878d7ba2b2e95df8d0d59caa63019c1ac8cd198f.tar.gz
perlweeklychallenge-club-878d7ba2b2e95df8d0d59caa63019c1ac8cd198f.tar.bz2
perlweeklychallenge-club-878d7ba2b2e95df8d0d59caa63019c1ac8cd198f.zip
Merge pull request #3328 from tylerw/tw/challenge-096
Challenge 096
Diffstat (limited to 'challenge-096/tyler-wardhaugh/lua/ch-1.lua')
-rwxr-xr-xchallenge-096/tyler-wardhaugh/lua/ch-1.lua25
1 files changed, 25 insertions, 0 deletions
diff --git a/challenge-096/tyler-wardhaugh/lua/ch-1.lua b/challenge-096/tyler-wardhaugh/lua/ch-1.lua
new file mode 100755
index 0000000000..6538be9718
--- /dev/null
+++ b/challenge-096/tyler-wardhaugh/lua/ch-1.lua
@@ -0,0 +1,25 @@
+#!/usr/bin/env lua
+
+local t1 = {}
+t1.DEFAULT_INPUT = 'The Weekly Challenge'
+
+function t1.reverse_words(s)
+ local words = {}
+ for word in s:gmatch('%S+') do
+ table.insert(words, 1, word)
+ end
+ return table.concat(words, ' ')
+end
+
+function t1.run(args)
+ local s
+ if #args > 0 then
+ s = args[1]
+ else
+ s = t1.DEFAULT_INPUT
+ end
+
+ print(t1.reverse_words(s))
+end
+
+return t1