aboutsummaryrefslogtreecommitdiff
path: root/challenge-096/tyler-wardhaugh/lua/ch-1.lua
diff options
context:
space:
mode:
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