aboutsummaryrefslogtreecommitdiff
path: root/challenge-279/roger-bell-west/lua/ch-2.lua
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-279/roger-bell-west/lua/ch-2.lua')
-rwxr-xr-xchallenge-279/roger-bell-west/lua/ch-2.lua44
1 files changed, 44 insertions, 0 deletions
diff --git a/challenge-279/roger-bell-west/lua/ch-2.lua b/challenge-279/roger-bell-west/lua/ch-2.lua
new file mode 100755
index 0000000000..92edbe4bd6
--- /dev/null
+++ b/challenge-279/roger-bell-west/lua/ch-2.lua
@@ -0,0 +1,44 @@
+#! /usr/bin/lua
+
+function split(t)
+ local cl = {}
+ string.gsub(t,
+ "(.)",
+ function(c)
+ table.insert(cl, c)
+ end
+ )
+ return cl
+end
+
+function splitstring(a)
+ local n = 0
+ for _, cc in ipairs(split(string.lower(a))) do
+ if string.find(cc, "[aeiou]") == 1 then
+ n = n + 1
+ end
+ end
+ return n % 2 == 0
+end
+
+if not splitstring("perl") then
+ io.write("Pass")
+else
+ io.write("FAIL")
+end
+io.write(" ")
+
+if splitstring("book") then
+ io.write("Pass")
+else
+ io.write("FAIL")
+end
+io.write(" ")
+
+if splitstring("goodmorning") then
+ io.write("Pass")
+else
+ io.write("FAIL")
+end
+print("")
+