Advertisement
Guest User

Word Cube in Lua

a guest
Jul 20th, 2010
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.40 KB | None | 0 0
  1. -- q contains all the letters from s?
  2. function containedIn(s,q)
  3.     local r
  4.     for i=1,#s do
  5.         q,r=string.gsub(q,string.sub(s,i,i),"",1)
  6.         if r==0 then return false end
  7.     end
  8.     return true
  9. end
  10.  
  11. function cubeWords(q)
  12.     q5=string.sub(q,5,5)
  13.     for l in io.lines("words.txt") do
  14.         l=string.lower(l)
  15.         if #l>3 and string.find(l,q5) and containedIn(l,q) then
  16.         print(l)
  17.         end
  18.     end
  19. end
  20.  
  21. cubeWords("ncbcioune")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement