For example, I have a keyword "abandoned" and I want to find the words that contains letters of this keyword such as "done", "abandon", band", from the arrays I stored those words. How can I search it?
I tried to write this code but not working properly. I wrote a function which takes the keyword and the word. Then i put letters of keyword to keywordletters array and the letters of the word into wordletters array.
Then i wrote a loop for matching letters. If the wordletters array match with the letter of keywordletters array, then i assigned the current wordletters element nil and then i made the keywordletters element nil. Because we can't use it second time.
After all loops, i checked the wordletters array. If it has an element which is not nil then i returned false. However, it's not working how i want. Can you help me out?
EDIT: ıI solved my problem and edited the code accordingly.
Here is my code:
function consistLetters(keyword,word)
keywordletters={ }
wordletters= { }
local found=false
findLetters(keyword,keywordletters)
findLetters(word,wordletters)
for i=1, #wordletters,1 do
for j=1, #keywordletters,1 do
if(keywordletters[j]~="") then
if(wordletters[i]==keywordletters[j]) then
keywordletters[j]=""
found=true;
break
end
end
end
if found~=true then
return false
end
found=false;
end
end