Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- lua solution to codabbey challenge 72
- function split(s, delimiter)
- result = {};
- for match in (s..delimiter):gmatch("(.-)"..delimiter) do
- table.insert(result, match);
- end
- return result;
- end
- function map(func, array)
- local new_array = {}
- for i,v in ipairs(array) do
- new_array[i] = func(v)
- end
- return new_array
- end
- INP1 = map(tonumber, split(io.read(), " "))
- INP2 = map(tonumber, split(io.read(), " "))
- CON = {}
- con = "bcdfghjklmnprstvwxz"
- con:gsub(".",function(c) table.insert(CON,c) end)
- VOW = {}
- vow = "aeiou"
- vow:gsub(".",function(c) table.insert(VOW,c) end)
- A = 445
- C = 700001
- M = 2097152
- XN = INP1[2]
- LI = 0
- RSP = {}
- for k, wl in pairs(INP2) do
- WORD = {}
- for i=1,wl do
- XN = (A*XN + C) % M
- if i % 2 == 0 then
- LI = XN % 5
- table.insert(WORD, VOW[LI+1])
- else
- LI = XN % 19
- table.insert(WORD, CON[LI+1])
- end
- end
- aux = table.concat(WORD, "")
- table.insert(RSP, aux)
- end
- print(table.concat(RSP, " "))
Add Comment
Please, Sign In to add comment