Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env lua
- -- https://www.codewars.com/kata/55c45be3b2079eccff00010f
- function mysplit(inputstr, sep)
- if sep == nil then sep = "%s" end
- local t = {}
- for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
- table.insert(t, str)
- end
- return t
- end
- function order(words)
- local words = mysplit(words)
- local mytable = {}
- for useless_key, word in pairs(words) do
- local buffer = ""
- print(buffer)
- local number = 0
- for i = 1, #word do
- local character = word:sub(i,i)
- if tonumber(character, 10) then
- number = tonumber(character, 10)
- else
- buffer = buffer . character
- end
- end
- print(buffer, number)
- mytable[number] = buffer
- end
- end
- order("ananas2 pineapple1")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement