Word Cube in Lua

a guest Jul 20th, 2010 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
  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
  21. cubeWords("ncbcioune")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand