diff options
Diffstat (limited to 'challenge-348/roger-bell-west/lua/ch-1.lua')
| -rwxr-xr-x | challenge-348/roger-bell-west/lua/ch-1.lua | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/challenge-348/roger-bell-west/lua/ch-1.lua b/challenge-348/roger-bell-west/lua/ch-1.lua new file mode 100755 index 0000000000..3261a885d6 --- /dev/null +++ b/challenge-348/roger-bell-west/lua/ch-1.lua @@ -0,0 +1,75 @@ +#! /usr/bin/lua + +function split(t) + local cl = {} + string.gsub(t, + "(.)", + function(c) + table.insert(cl, c) + end + ) + return cl +end + +function is_vowel(c) + if string.find(c, "[aeiou]") == 1 then + return true + else + return false + end +end + +function stringalike(a) + if #a % 2 == 1 then + return false + end + local vt = 0 + local mode = 1 + local av = false + for i,c in ipairs(split(string.lower(a))) do + if is_vowel(c) then + av = true + vt = vt + mode + end + if i * 2 == #a then + mode = -1 + end + end + return av and (vt == 0) +end + +if not stringalike("textbook") then + io.write("Pass") +else + io.write("FAIL") +end +io.write(" ") + +if stringalike("book") then + io.write("Pass") +else + io.write("FAIL") +end +io.write(" ") + +if stringalike("AbCdEfGh") then + io.write("Pass") +else + io.write("FAIL") +end +io.write(" ") + +if not stringalike("rhythmmyth") then + io.write("Pass") +else + io.write("FAIL") +end +io.write(" ") + +if not stringalike("UmpireeAudio") then + io.write("Pass") +else + io.write("FAIL") +end +print("") + |
